Enum rocket::config::Environment [−][src]
pub enum Environment {
Development,
Staging,
Production,
}Expand description
An enum corresponding to the valid configuration environments.
Variants
The development environment.
The staging environment.
The production environment.
Implementations
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.
Returns true if self is Environment::Development.
Example
use rocket::config::Environment;
assert!(Environment::Development.is_dev());
assert!(!Environment::Production.is_dev());Returns true if self is Environment::Staging.
Example
use rocket::config::Environment;
assert!(Environment::Staging.is_stage());
assert!(!Environment::Production.is_stage());Trait Implementations
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);Auto Trait Implementations
impl RefUnwindSafe for Environment
impl Send for Environment
impl Sync for Environment
impl Unpin for Environment
impl UnwindSafe for Environment
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.