Struct sea_orm_rocket::figment::Profile
[−]pub struct Profile(_);Expand description
A configuration profile: effectively a case-insensitive string.
See the top-level docs for details.
Implementations
impl Profile
impl Profile
pub 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");pub 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");pub fn from_env(key: &str) -> Option<Profile>
pub fn from_env(key: &str) -> Option<Profile>
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(())
});pub fn from_env_or<P>(var: &str, default: P) -> Profilewhere
P: Into<Profile>,
pub fn from_env_or<P>(var: &str, default: P) -> Profilewhere
P: Into<Profile>,
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(())
});pub 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();pub 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"));pub fn is_custom(&self) -> bool
pub fn is_custom(&self) -> bool
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: BTreeMap<String, Value, Global>
) -> BTreeMap<Profile, BTreeMap<String, Value, Global>, Global>
pub fn collect(
&self,
dict: BTreeMap<String, Value, Global>
) -> BTreeMap<Profile, BTreeMap<String, Value, Global>, Global>
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
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!");pub 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);pub 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());pub 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
impl Deref for Profile
impl Deref for Profile
type Target = UncasedStr
type Target = UncasedStr
fn deref(&self) -> &UncasedStr
fn deref(&self) -> &UncasedStr
impl<'de> Deserialize<'de> for Profile
impl<'de> Deserialize<'de> for Profile
fn deserialize<D>(
deserializer: D
) -> Result<Profile, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<Profile, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
impl Ord for Profile
impl Ord for Profile
1.21.0 · sourceconst fn max(self, other: Self) -> Self
const fn max(self, other: Self) -> Self
1.21.0 · sourceconst fn min(self, other: Self) -> Self
const fn min(self, other: Self) -> Self
1.50.0 · sourceconst fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
const fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
impl PartialOrd<Profile> for Profile
impl PartialOrd<Profile> for Profile
fn partial_cmp(&self, other: &Profile) -> Option<Ordering>
fn partial_cmp(&self, other: &Profile) -> Option<Ordering>
1.0.0 · sourceconst fn le(&self, other: &Rhs) -> bool
const fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moreimpl Serialize for Profile
impl Serialize for Profile
fn serialize<S>(
&self,
s: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
s: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl Eq for Profile
impl StructuralEq for Profile
impl StructuralPartialEq for Profile
Auto Trait Implementations
impl RefUnwindSafe for Profile
impl Send for Profile
impl Sync for Profile
impl Unpin for Profile
impl UnwindSafe for Profile
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
fn into_collection<A>(self) -> SmallVec<A>where
A: Array<Item = T>,
self into a collection.