pub enum Environment {
Development,
Production,
}Expand description
Environment configuration for error handling behavior
Controls whether internal error details are exposed in API responses. In production, internal details are masked to prevent information leakage. In development, full error details are shown for debugging.
§Example
use rustapi_core::Environment;
let dev = Environment::Development;
assert!(dev.is_development());
assert!(!dev.is_production());
let prod = Environment::Production;
assert!(prod.is_production());
assert!(!prod.is_development());Variants§
Development
Development mode - shows full error details in responses
Production
Production mode - masks internal error details in responses
Implementations§
Source§impl Environment
impl Environment
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Detect environment from RUSTAPI_ENV environment variable
Returns Production if RUSTAPI_ENV is set to “production” or “prod” (case-insensitive).
Returns Development for all other values or if the variable is not set.
§Example
# Production mode
RUSTAPI_ENV=production cargo run
RUSTAPI_ENV=prod cargo run
# Development mode (default)
RUSTAPI_ENV=development cargo run
cargo run # No env var setSourcepub fn is_production(&self) -> bool
pub fn is_production(&self) -> bool
Check if this is production environment
Sourcepub fn is_development(&self) -> bool
pub fn is_development(&self) -> bool
Check if this is development environment
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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Environment
impl Debug for Environment
Source§impl Default for Environment
impl Default for Environment
Source§fn default() -> Environment
fn default() -> Environment
Returns the “default value” for a type. Read more
Source§impl Display for Environment
impl Display for Environment
Source§impl PartialEq for Environment
impl PartialEq for Environment
impl Copy for Environment
impl Eq for Environment
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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> ValidateIp for Twhere
T: ToString,
impl<T> ValidateIp for Twhere
T: ToString,
Source§fn validate_ipv4(&self) -> bool
fn validate_ipv4(&self) -> bool
Validates whether the given string is an IP V4
Source§fn validate_ipv6(&self) -> bool
fn validate_ipv6(&self) -> bool
Validates whether the given string is an IP V6
Source§fn validate_ip(&self) -> bool
fn validate_ip(&self) -> bool
Validates whether the given string is an IP