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§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.