pub struct Environment { /* private fields */ }Expand description
Layered environment with typed dependencies (UDF DependencyValues + scoped overrides).
Implementations§
Source§impl Environment
impl Environment
pub fn new() -> Self
pub fn live() -> Self
pub fn test() -> Self
pub fn from_values(base: DependencyValues) -> Self
pub fn values(&self) -> DependencyValues
pub fn get<D: Send + Sync + 'static>(&self) -> Option<Arc<D>>
pub fn require<D: Send + Sync + 'static>( &self, ) -> Result<Arc<D>, DependencyError>
pub fn with<D: Send + Sync + 'static>(self, value: D) -> Self
pub fn push_values(&self, overlay: DependencyValues)
Sourcepub fn scoped_with(&self, overlay: Environment) -> Self
pub fn scoped_with(&self, overlay: Environment) -> Self
Fork the environment and append overlay dependency layers (for Effect::provide).
pub fn with_clock(self, clock: FakeClock) -> Self
pub fn with_http(self, http: MockHttp) -> Self
pub fn clock(&self) -> Option<FakeClock>
pub fn http(&self) -> Option<MockHttp>
Sourcepub fn push_layer(&self, overlay: Environment)
pub fn push_layer(&self, overlay: Environment)
Back-compat alias for Self::scoped_with.
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 moreSource§impl Debug for Environment
impl Debug for Environment
Auto Trait Implementations§
impl !RefUnwindSafe for Environment
impl !UnwindSafe for Environment
impl Freeze for Environment
impl Send for Environment
impl Sync for Environment
impl Unpin for Environment
impl UnsafeUnpin 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