logo
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

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());

Returns true if self is Environment::Production.

Example
use rocket::config::Environment;

assert!(Environment::Production.is_prod());
assert!(!Environment::Staging.is_prod());

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

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);

The associated error which can be returned from parsing.

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 !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts self into a collection.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Get the TypeId of this object.