pub enum Environment {
Development,
Production,
}Expand description
Where the Worker runs, from its build profile (Rails’ Rails.env, Loco’s environment).
ocre dev and cargo test build with debug assertions
(Development); ocre deploy builds in release mode
(Production). Rails’ test environment is
Development here: tests run the debug build natively. Values that
differ per environment go in .dev.vars (development) and
cloudflare.config.ts or secrets (production), read with
Ctx::config.
§Examples
use ocre::config::Environment;
let env = Environment::current();
assert_eq!(env.is_development(), cfg!(debug_assertions));
assert_eq!(Environment::Production.as_str(), "production");Variants§
Implementations§
Source§impl Environment
impl Environment
Sourcepub fn current() -> Self
pub fn current() -> Self
The environment of this build.
§Examples
assert!(ocre::config::Environment::current().is_development() || cfg!(not(debug_assertions)));Sourcepub fn as_str(self) -> &'static str
pub fn as_str(self) -> &'static str
development or production, as sent to error reporters.
§Examples
assert_eq!(ocre::config::Environment::Development.as_str(), "development");Sourcepub fn is_development(self) -> bool
pub fn is_development(self) -> bool
Whether this is Development.
§Examples
assert!(!ocre::config::Environment::Production.is_development());Trait Implementations§
Source§impl Clone for Environment
impl Clone for Environment
Source§fn clone(&self) -> Environment
fn clone(&self) -> Environment
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for Environment
Source§impl Debug for Environment
impl Debug for Environment
impl Eq for Environment
Source§impl PartialEq for Environment
impl PartialEq for Environment
Source§fn eq(&self, other: &Environment) -> bool
fn eq(&self, other: &Environment) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for Environment
Auto Trait Implementations§
impl Freeze for Environment
impl RefUnwindSafe for Environment
impl Send for Environment
impl Sync for Environment
impl Unpin for Environment
impl UnsafeUnpin for Environment
impl UnwindSafe for Environment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.