pub struct Config { /* private fields */ }
Expand description
The configuration object for Freedom.
Used when creating a Freedom API client
Implementations§
Source§impl Config
impl Config
Sourcepub const ATLAS_ENV_VAR: &'static str = "ATLAS_ENV"
pub const ATLAS_ENV_VAR: &'static str = "ATLAS_ENV"
The environment variable name for the atlas environment
Sourcepub const ATLAS_KEY_VAR: &'static str = "ATLAS_KEY"
pub const ATLAS_KEY_VAR: &'static str = "ATLAS_KEY"
The environment variable name for the atlas key
Sourcepub const ATLAS_SECRET_VAR: &'static str = "ATLAS_SECRET"
pub const ATLAS_SECRET_VAR: &'static str = "ATLAS_SECRET"
The environment variable name for the atlas secret
Sourcepub fn builder() -> ConfigBuilder
pub fn builder() -> ConfigBuilder
Construct a new config builder
§Example
let config_result = Config::builder()
.environment(Test)
.key("my_key")
.secret("my_secret")
.build();
assert!(config_result.is_ok());
Sourcepub fn from_env() -> Result<Config, Error>
pub fn from_env() -> Result<Config, Error>
Build the entire configuration from environment variables
Sourcepub fn new(
environment: impl Env,
key: impl Into<String>,
secret: impl Into<String>,
) -> Config
pub fn new( environment: impl Env, key: impl Into<String>, secret: impl Into<String>, ) -> Config
Construct the Config from the environment, key, and secret
§Example
let config = Config::new(Test, "my_key", "my_secret");
Sourcepub fn set_environment(&mut self, environment: impl Env)
pub fn set_environment(&mut self, environment: impl Env)
Set the environment
§Example
config.set_environment(Prod);
assert_eq!(config.environment_str(), "prod");
Sourcepub fn environment(&self) -> &Environment
pub fn environment(&self) -> &Environment
Return the trait object representing an ATLAS environment
Sourcepub fn environment_str(&self) -> &str
pub fn environment_str(&self) -> &str
Return the string representation of the environment
Sourcepub fn expose_secret(&self) -> &str
pub fn expose_secret(&self) -> &str
Exposes the secret as a string slice.
§Warning
Use this with extreme care to avoid accidentally leaking your key
Sourcepub fn set_secret(&mut self, secret: impl Into<String>)
pub fn set_secret(&mut self, secret: impl Into<String>)
Set the value of the ATLAS secret
§Example
config.set_secret("top secret");
assert_eq!(config.expose_secret(), "top secret");
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 !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