Enum rocket::config::Environment
source · [−]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
sourceimpl 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
sourceimpl Clone for Environment
impl Clone for Environment
sourcefn clone(&self) -> Environment
fn clone(&self) -> Environment
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Environment
impl Debug for Environment
sourceimpl Display for Environment
impl Display for Environment
sourceimpl FromStr for Environment
impl FromStr for Environment
sourcefn 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);
sourceimpl Hash for Environment
impl Hash for Environment
sourceimpl PartialEq<Environment> for Environment
impl PartialEq<Environment> for Environment
impl Copy for Environment
impl Eq for Environment
impl StructuralEq for Environment
impl StructuralPartialEq for Environment
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
sourcefn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
Converts self
into a collection.
fn mapped<U, F, A>(self, f: F) -> SmallVec<A> where
F: FnMut(T) -> U,
A: Array<Item = U>,
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more