Enum rocket::config::Environment
source · pub enum Environment {
Development,
Staging,
Production,
}
Expand description
An enum corresponding to the valid configuration environments.
Variants§
Development
The development environment.
Staging
The staging environment.
Production
The production environment.
Implementations§
source§impl Environment
impl Environment
sourcepub fn active() -> Result<Environment, ConfigError>
pub fn active() -> Result<Environment, ConfigError>
Retrieves the “active” environment as determined by the ROCKET_ENV
environment variable. If ROCKET_ENV
is not set, returns Development
when the application was compiled in debug
mode and Production
when
the application was compiled in release
mode.
§Errors
Returns a BadEnv
ConfigError
if ROCKET_ENV
is set and contains an
invalid or unknown environment name.
sourcepub fn is_dev(self) -> bool
pub fn is_dev(self) -> bool
Returns true
if self
is Environment::Development
.
§Example
use rocket::config::Environment;
assert!(Environment::Development.is_dev());
assert!(!Environment::Production.is_dev());
Trait Implementations§
source§impl Clone for Environment
impl Clone for Environment
source§fn clone(&self) -> Environment
fn clone(&self) -> Environment
Returns a copy 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 Display for Environment
impl Display for Environment
source§impl FromStr for Environment
impl FromStr for Environment
source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Parses a configuration environment from a string. Should be used
indirectly via str
’s parse
method.
§Examples
Parsing a development environment:
use rocket::config::Environment;
let env = "development".parse::<Environment>();
assert_eq!(env.unwrap(), Environment::Development);
let env = "dev".parse::<Environment>();
assert_eq!(env.unwrap(), Environment::Development);
let env = "devel".parse::<Environment>();
assert_eq!(env.unwrap(), Environment::Development);
Parsing a staging environment:
use rocket::config::Environment;
let env = "staging".parse::<Environment>();
assert_eq!(env.unwrap(), Environment::Staging);
let env = "stage".parse::<Environment>();
assert_eq!(env.unwrap(), Environment::Staging);
Parsing a production environment:
use rocket::config::Environment;
let env = "production".parse::<Environment>();
assert_eq!(env.unwrap(), Environment::Production);
let env = "prod".parse::<Environment>();
assert_eq!(env.unwrap(), Environment::Production);
source§impl Hash for Environment
impl Hash for Environment
source§impl PartialEq for Environment
impl PartialEq for Environment
impl Copy for Environment
impl Eq 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
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
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.