pub struct Profile(/* private fields */);Expand description
A configuration profile: effectively a case-insensitive string.
See the top-level docs for details.
Implementations§
Source§impl Profile
impl Profile
Sourcepub fn new(name: &str) -> Profile
pub fn new(name: &str) -> Profile
Constructs a profile with the name name.
§Example
use figment::Profile;
let profile = Profile::new("staging");
assert_eq!(profile, "staging");
assert_eq!(profile, "STAGING");Sourcepub const fn const_new(name: &'static str) -> Profile
pub const fn const_new(name: &'static str) -> Profile
A const to construct a profile with the name name.
§Example
use figment::Profile;
const STAGING: Profile = Profile::const_new("staging");
assert_eq!(STAGING, "staging");
assert_eq!(STAGING, "STAGING");Sourcepub fn from_env(key: &str) -> Option<Self>
pub fn from_env(key: &str) -> Option<Self>
Constructs a profile from the value of the environment variable with
name key, if one is present. The search for key is case-insensitive.
§Example
use figment::{Profile, Jail};
Jail::expect_with(|jail| {
jail.set_env("MY_PROFILE", "secret");
assert_eq!(Profile::from_env("MY_PROFILE"), Some("secret".into()));
assert_eq!(Profile::from_env("MY_PROFILE"), Some("secret".into()));
assert_eq!(Profile::from_env("MY_profile"), Some("secret".into()));
assert_eq!(Profile::from_env("other_profile"), None);
Ok(())
});Sourcepub fn from_env_or<P: Into<Profile>>(var: &str, default: P) -> Self
pub fn from_env_or<P: Into<Profile>>(var: &str, default: P) -> Self
Constructs a profile from the value of the environment variable with
name var, if one is present, or default if one is not. The search
for var is case-insensitive.
§Example
use figment::{Profile, Jail};
Jail::expect_with(|jail| {
jail.set_env("MY_PROFILE", "secret");
assert_eq!(Profile::from_env_or("MY_PROFILE", "default"), "secret");
assert_eq!(Profile::from_env_or("MY_profile", "default"), "secret");
assert_eq!(Profile::from_env_or("other_prof", "default"), "default");
Ok(())
});Sourcepub fn as_str(&self) -> &UncasedStr
pub fn as_str(&self) -> &UncasedStr
Converts self into an &UncasedStr.
§Example
use figment::Profile;
let profile = Profile::new("static");
let string = profile.as_str();Sourcepub fn starts_with(&self, prefix: &str) -> bool
pub fn starts_with(&self, prefix: &str) -> bool
Returns true iff self case-insensitively starts with prefix.
§Example
use figment::Profile;
let profile = Profile::new("static");
assert!(profile.starts_with("STAT"));
assert!(profile.starts_with("stat"));
assert!(profile.starts_with("static"));Methods from Deref<Target = UncasedStr>§
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns self as an &str.
§Example
use uncased::UncasedStr;
let uncased_str = UncasedStr::new("Hello!");
assert_eq!(uncased_str.as_str(), "Hello!");
assert_ne!(uncased_str.as_str(), "hELLo!");Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length, in bytes, of self.
§Example
use uncased::UncasedStr;
let uncased_str = UncasedStr::new("Hello!");
assert_eq!(uncased_str.len(), 6);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if self has a length of zero bytes.
§Examples
use uncased::UncasedStr;
let s = UncasedStr::new("");
assert!(s.is_empty());
let s = UncasedStr::new("not empty");
assert!(!s.is_empty());Sourcepub fn starts_with(&self, string: &str) -> bool
pub fn starts_with(&self, string: &str) -> bool
Returns true if self starts with any casing of the string string;
otherwise, returns false.
§Example
use uncased::UncasedStr;
let uncased_str = UncasedStr::new("MoOO");
assert!(uncased_str.starts_with("moo"));
assert!(uncased_str.starts_with("MOO"));
assert!(uncased_str.starts_with("MOOO"));
assert!(!uncased_str.starts_with("boo"));
let uncased_str = UncasedStr::new("Bèe");
assert!(!uncased_str.starts_with("Be"));
assert!(uncased_str.starts_with("Bè"));
assert!(uncased_str.starts_with("Bè"));
assert!(uncased_str.starts_with("bèe"));
assert!(uncased_str.starts_with("BèE"));Trait Implementations§
Source§impl Deref for Profile
impl Deref for Profile
Source§type Target = UncasedStr
type Target = UncasedStr
Source§fn deref(&self) -> &UncasedStr
fn deref(&self) -> &UncasedStr
Source§impl<'de> Deserialize<'de> for Profile
impl<'de> Deserialize<'de> for Profile
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Ord for Profile
impl Ord for Profile
Source§impl PartialOrd for Profile
impl PartialOrd for Profile
impl Eq for Profile
impl StructuralPartialEq for Profile
Auto Trait Implementations§
impl Freeze for Profile
impl RefUnwindSafe for Profile
impl Send for Profile
impl Sync for Profile
impl Unpin for Profile
impl UnwindSafe for Profile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 24 bytes