Enum rocket::config::Environment
[−]
[src]
pub enum Environment { Development, Staging, Production, }
An enum corresponding to the valid configuration environments.
Variants
Development
The development environment.
Staging
The staging environment.
Production
The production environment.
Methods
impl Environment
[src]
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
.
Errors
Returns a BadEnv
ConfigError
if ROCKET_ENV
contains an invalid
environment name.
Trait Implementations
impl Hash for Environment
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialEq for Environment
[src]
fn eq(&self, __arg_0: &Environment) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl Eq for Environment
[src]
impl Debug for Environment
[src]
impl Clone for Environment
[src]
fn clone(&self) -> Environment
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Copy for Environment
[src]
impl FromStr for Environment
[src]
type Err = ()
The associated error which can be returned from parsing.
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);