pub enum EnvType {
Dev,
Test,
Stg,
Prod,
}Expand description
EnvType is an enum that represents the environment type. EnvType is derived from the strum crate, which provides the ability to convert the string to the enum.
§Example
use env_type::types::EnvType;
use std::str::FromStr;
let env = EnvType::from_str("d").unwrap();
assert_eq!(EnvType::Dev, env);Variants§
Implementations§
source§impl EnvType
impl EnvType
sourcepub fn from_env() -> Self
pub fn from_env() -> Self
EnvType::from_env is a function that returns the environment type from the environment variable. This is deligated to from_env_key with EnvType as default from env key. The default environment type is Dev.
§Example
use env_type::types::EnvType;
use std::str::FromStr;
std::env::set_var("ENV", "Production");
let env = EnvType::from_env();
assert_eq!(EnvType::Prod, env);sourcepub fn from_env_key<T: EnvKey>() -> Self
pub fn from_env_key<T: EnvKey>() -> Self
EnvType::from_env_key is a function that returns the environment type from the environment variable. The default environment type is Dev. /// # Example
use env_type::types::EnvType;
use std::str::FromStr;
std::env::set_var("ENV", "Test");
let env = EnvType::from_env_key::<EnvType>();
assert_eq!(EnvType::Test, env);Trait Implementations§
source§impl EnvKey for EnvType
impl EnvKey for EnvType
EnvType is an implementation of the EnvKey trait. The default environment key is “ENV”.
impl Copy for EnvType
impl Eq for EnvType
impl StructuralPartialEq for EnvType
Auto Trait Implementations§
impl Freeze for EnvType
impl RefUnwindSafe for EnvType
impl Send for EnvType
impl Sync for EnvType
impl Unpin for EnvType
impl UnwindSafe for EnvType
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)