pub struct Config { /* private fields */ }Expand description
The application’s configuration tree.
Cloning is cheap: every clone shares one store, so a handler can hold a
Config without copying the tree.
Implementations§
Source§impl Config
impl Config
pub fn new() -> Self
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Seed the tree with the framework’s defaults, honouring .env.
Sourcepub fn load_dir(&self, dir: impl AsRef<Path>) -> Result<()>
pub fn load_dir(&self, dir: impl AsRef<Path>) -> Result<()>
Load every config/*.json file, keyed by file stem.
config/app.json becomes the app.* namespace, mirroring Laravel’s
config/app.php. String values support ${VAR} interpolation so a
config file can defer to .env.
Sourcepub fn set(&self, path: &str, value: impl Into<Json>)
pub fn set(&self, path: &str, value: impl Into<Json>)
Set (or replace) a value at a dotted path.
Sourcepub fn merge(&self, namespace: &str, value: Json)
pub fn merge(&self, namespace: &str, value: Json)
Merge an object into a namespace, keeping keys that are not overridden.
pub fn string(&self, path: &str, default: &str) -> String
pub fn int(&self, path: &str, default: i64) -> i64
pub fn bool(&self, path: &str, default: bool) -> bool
Sourcepub fn environment(&self) -> String
pub fn environment(&self) -> String
The current environment name: local, production, testing.
pub fn is_local(&self) -> bool
pub fn is_production(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
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