pub enum Environment {
Development,
Staging,
Production,
}
An enum corresponding to the valid configuration environments.
The development environment.
The production environment.
Returns true
if self
is Environment::Development
.
use rocket::config::Environment;
assert!(Environment::Development.is_dev());
assert!(!Environment::Production.is_dev());
Returns true
if self
is Environment::Staging
.
use rocket::config::Environment;
assert!(Environment::Staging.is_stage());
assert!(!Environment::Production.is_stage());
Returns true
if self
is Environment::Production
.
use rocket::config::Environment;
assert!(Environment::Production.is_prod());
assert!(!Environment::Staging.is_prod());
Retrieves the "active" environment as determined by the ROCKET_ENV
environment variable. If ROCKET_ENV
is not set, returns Development
.
Returns a BadEnv
ConfigError
if ROCKET_ENV
contains an invalid
environment name.
Feeds this value into the given [Hasher
]. Read more
Feeds a slice of this type into the given [Hasher
]. Read more
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Formats the value using the given formatter. Read more
Performs copy-assignment from source
. Read more
The associated error which can be returned from parsing.
Parses a configuration environment from a string. Should be used
indirectly via str
's parse
method.
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);
Formats the value using the given formatter. Read more