pub struct ModuleConfig<'a> { /* private fields */ }Expand description
Typed view over a Config for one module: prefixes every key with the
module name in SCREAMING_SNAKE and parses values with defaults
(issue #3).
use cratefield_core::{Config, ModuleConfig};
let cfg = MapConfig(
[("EMAIL_SIGNUP_CONFIRM_TTL_DAYS".to_string(), "3".to_string())]
.into_iter()
.collect(),
);
let module = ModuleConfig::new("email-signup", &cfg);
assert_eq!(module.get_u32("CONFIRM_TTL_DAYS", 7), 3);
assert_eq!(module.get_bool("DOUBLE_OPT_IN", true), true);
assert_eq!(module.get_str("FROM_NAME", "Factory Zero"), "Factory Zero");Implementations§
Source§impl<'a> ModuleConfig<'a>
impl<'a> ModuleConfig<'a>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for ModuleConfig<'a>
impl<'a> !UnwindSafe for ModuleConfig<'a>
impl<'a> Freeze for ModuleConfig<'a>
impl<'a> Send for ModuleConfig<'a>
impl<'a> Sync for ModuleConfig<'a>
impl<'a> Unpin for ModuleConfig<'a>
impl<'a> UnsafeUnpin for ModuleConfig<'a>
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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 more