pub struct Environment { /* private fields */ }Expand description
The effects a layer needs but must not reach for: time and randomness.
Cloning is cheap, both sources sit behind an Arc, so an Environment is
meant to be passed by value into the layers and recipes that need it and kept
alongside the Database.
§Example
// Production: machine clock, generator seeded from entropy.
let env = Environment::default();
// A reproducible run: the same seed replays the same sequence.
let env = Environment::with_seed(42);
let first = env.rng().next_u64();
assert_eq!(Environment::with_seed(42).rng().next_u64(), first);Implementations§
Trait Implementations§
Source§impl Clone for Environment
impl Clone for Environment
Source§fn clone(&self) -> Environment
fn clone(&self) -> Environment
Returns a copy 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
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