pub struct CONF;Expand description
Global configuration access point
Provides Total.js-style uniform configuration access using dot notation paths. This allows any part of the application to access configuration values without needing a Context or dependency injection.
Implementations§
Source§impl CONF
impl CONF
Sourcepub fn get<T: DeserializeOwned>(path: &str) -> Option<T>
pub fn get<T: DeserializeOwned>(path: &str) -> Option<T>
Get a configuration value by dot-notation path
Returns the value at the specified path, or None if the path doesn’t exist. The type T must implement Deserialize.
§Arguments
path- Dot-separated path to the configuration value
§Examples
ⓘ
let port: Option<u16> = CONF::get("server.port");
let db_url: Option<String> = CONF::get("database.url");Sourcepub fn get_string(path: &str) -> Option<String>
pub fn get_string(path: &str) -> Option<String>
Sourcepub fn get_int(path: &str) -> Option<i64>
pub fn get_int(path: &str) -> Option<i64>
Get an integer configuration value
Convenience method for getting integer values. Handles both i64 and u64 internally.
§Arguments
path- Dot-separated path to the configuration value
§Examples
ⓘ
let port = CONF::get_int("server.port").unwrap_or(8000);
let max_connections = CONF::get_int("server.max_connections");Sourcepub fn get_or<T: DeserializeOwned>(path: &str, default: T) -> T
pub fn get_or<T: DeserializeOwned>(path: &str, default: T) -> T
Get a configuration value with a default
Returns the value at the specified path, or the default if the path doesn’t exist.
§Arguments
path- Dot-separated path to the configuration valuedefault- Default value to return if path doesn’t exist
§Examples
ⓘ
let port = CONF::get_or("server.port", 8000);
let timeout = CONF::get_or("server.timeout", 30);Sourcepub fn is_production() -> bool
pub fn is_production() -> bool
Sourcepub fn is_development() -> bool
pub fn is_development() -> bool
Sourcepub fn is_initialized() -> bool
pub fn is_initialized() -> bool
Auto Trait Implementations§
impl Freeze for CONF
impl RefUnwindSafe for CONF
impl Send for CONF
impl Sync for CONF
impl Unpin for CONF
impl UnsafeUnpin for CONF
impl UnwindSafe for CONF
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<T> ErasedDestructor for Twhere
T: 'static,
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