pub enum Environment {
Local,
Test,
Stage,
Production,
}Expand description
Possible deployment environments for an application.
Variants§
Implementations§
Source§impl Environment
impl Environment
Sourcepub fn init() -> Result<Self>
pub fn init() -> Result<Self>
Get the value from the environment variable APP_ENV.
It raise an error if the string doesn’t match a possible environment.
§Examples
use std::env;
use server_env_config::env::Environment;
env::set_var("APP_ENV", "production");
assert!(matches!(Environment::init(), Ok(Environment::Production)));
env::set_var("APP_ENV", "Not a environment");
assert!(Environment::init().is_err());
env::remove_var("APP_ENV"); // if not set, local environment is the default
assert!(matches!(Environment::init(), Ok(Environment::Local)));Trait Implementations§
Source§impl Clone for Environment
impl Clone for Environment
Source§fn clone(&self) -> Environment
fn clone(&self) -> Environment
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 Environment
impl Debug for Environment
Source§impl Default for Environment
impl Default for Environment
Source§fn default() -> Environment
fn default() -> Environment
Returns the “default value” for a type. Read more
Source§impl Display for Environment
impl Display for Environment
Source§impl FromStr for Environment
impl FromStr for Environment
Source§impl PartialEq for Environment
impl PartialEq for Environment
Source§impl TryFrom<&str> for Environment
impl TryFrom<&str> for Environment
impl StructuralPartialEq for Environment
Auto Trait Implementations§
impl Freeze for Environment
impl RefUnwindSafe for Environment
impl Send for Environment
impl Sync for Environment
impl Unpin for Environment
impl UnwindSafe for Environment
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