Struct figment::Profile [−][src]
A configuration profile: effectively a case-insensitive string.
See the top-level docs for details.
Implementations
impl Profile
[src]
pub const Default: Profile
[src]
The default profile: "default"
.
pub const Global: Profile
[src]
The global profile: "global"
.
pub fn new(name: &str) -> Profile
[src]
Constructs a profile with the name name
.
Example
use figment::Profile; let profile = Profile::new("staging"); assert_eq!(profile, "staging"); assert_eq!(profile, "STAGING");
pub const fn const_new(name: &'static str) -> Profile
[src]
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");
pub fn from_env(key: &str) -> Option<Self>
[src]
Constructs a profile from the value of the environment variable with
name name
, if one is present. The search for name
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(()) });
pub fn from_env_or<P: Into<Profile>>(var: &str, default: P) -> Self
[src]
Constructs a profile from the value of the environment variable with
name name
, if one is present, or default
if one is not. The search
for name
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(()) });
pub fn as_str(&self) -> &UncasedStr
[src]
Converts self
into an &UncasedStr
.
Example
use figment::Profile; let profile = Profile::new("static"); let string = profile.as_str();
pub fn starts_with(&self, prefix: &str) -> bool
[src]
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"));
pub fn is_custom(&self) -> bool
[src]
Returns true
iff self
is neither "default" nor "global".
Example
use figment::Profile; let profile = Profile::new("static"); assert!(profile.is_custom()); assert!(!Profile::Default.is_custom()); assert!(!Profile::Global.is_custom());
pub fn collect(&self, dict: Dict) -> Map<Profile, Dict>
[src]
Creates a new map with a single key of *self
and a value of dict
.
Example
use figment::{Profile, util::map}; let profile = Profile::new("static"); let map = profile.collect(map!["hi".into() => 123.into()]);
Methods from Deref<Target = UncasedStr>
pub fn as_str(&self) -> &str
[src]
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!");
pub fn len(&self) -> usize
[src]
Returns the length, in bytes, of self
.
Example
use uncased::UncasedStr; let uncased_str = UncasedStr::new("Hello!"); assert_eq!(uncased_str.len(), 6);
pub fn starts_with(&self, string: &str) -> bool
[src]
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"));
Trait Implementations
impl Clone for Profile
[src]
impl Debug for Profile
[src]
impl Default for Profile
[src]
impl Deref for Profile
[src]
impl<'de> Deserialize<'de> for Profile
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl Display for Profile
[src]
impl Eq for Profile
[src]
impl From<Profile> for String
[src]
impl<T: AsRef<str>> From<T> for Profile
[src]
impl Hash for Profile
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl Ord for Profile
[src]
fn cmp(&self, other: &Profile) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<&'_ Profile> for Profile
[src]
fn eq(&self, other: &&Profile) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<&'_ str> for Profile
[src]
impl PartialEq<Profile> for Profile
[src]
impl PartialEq<Profile> for &Profile
[src]
fn eq(&self, other: &Profile) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialEq<str> for Profile
[src]
impl PartialOrd<Profile> for Profile
[src]
fn partial_cmp(&self, other: &Profile) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Serialize for Profile
[src]
impl StructuralEq for Profile
[src]
impl StructuralPartialEq for Profile
[src]
Auto Trait Implementations
impl RefUnwindSafe for Profile
[src]
impl Send for Profile
[src]
impl Sync for Profile
[src]
impl Unpin for Profile
[src]
impl UnwindSafe for Profile
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,