pub enum ConfigSource {
Env(EnvSourceOptions),
File(String, Option<FileSourceOptions>),
Custom(Box<dyn CustomConfigSource>),
}Expand description
Represents the source of configuration values.
This enum has three variants:
Env: Represents loading configuration values from OS environment variables.File: Represents loading configuration values from a JSON, YAML, or TOML file.Custom: Represents loading configuration values using a custom implementation ofCustomConfigSource.
§Examples
§Using Env variant with default path
use north_config::{ConfigSource, EnvSourceOptions};
let source = ConfigSource::Env(EnvSourceOptions::default());§Using Env variant with custom path
use north_config::{ConfigSource, EnvSourceOptions};
let source = ConfigSource::Env(EnvSourceOptions::default());§Using File variant
use north_config::ConfigSource;
let source = ConfigSource::File(String::from("config.json"), None);§Using Custom variant with a custom implementation
use north_config::{ConfigSource, CustomConfigSource, Error};
#[derive(Clone, Debug)]
struct MyCustomSource;
impl CustomConfigSource for MyCustomSource {
// implementation details here
fn get_config_value(&self) -> Result<serde_json::Value, Error> {
todo!()
}
}
let source = ConfigSource::Custom(Box::new(MyCustomSource));Variants§
Env(EnvSourceOptions)
§Env
loads from the OS env variables
§Example
With default path
use north_config::{ConfigSource, EnvSourceOptions};
ConfigSource::Env(EnvSourceOptions::default());With custom path
use north_config::{ConfigSource, EnvSourceOptions};
ConfigSource::Env(EnvSourceOptions::default());File(String, Option<FileSourceOptions>)
loads a json, YAML, OR TOML file
Custom(Box<dyn CustomConfigSource>)
loads a json, YAML, OR TOML file
Trait Implementations§
Source§impl Clone for ConfigSource
impl Clone for ConfigSource
Source§fn clone(&self) -> ConfigSource
fn clone(&self) -> ConfigSource
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ConfigSource
impl Debug for ConfigSource
Auto Trait Implementations§
impl Freeze for ConfigSource
impl !RefUnwindSafe for ConfigSource
impl Send for ConfigSource
impl Sync for ConfigSource
impl Unpin for ConfigSource
impl !UnwindSafe for ConfigSource
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