pub struct Context { /* private fields */ }Expand description
Implementation of crate::Spawner, crate::Clock,
crate::Network, and crate::Storage for the deterministic
runtime.
Implementations§
Source§impl Context
 
impl Context
Sourcepub fn recover(self) -> (Runner, Self, Arc<Auditor>)
 
pub fn recover(self) -> (Runner, Self, Arc<Auditor>)
Recover the inner state (deadline, metrics, auditor, rng, synced storage, etc.) from the current runtime and use it to initialize a new instance of the runtime. A recovered runtime does not inherit the current runtime’s pending tasks, unsynced storage, network connections, nor its shutdown signaler.
This is useful for performing a deterministic simulation that spans multiple runtime instantiations, like simulating unclean shutdown (which involves repeatedly halting the runtime at unexpected intervals).
It is only permitted to call this method after the runtime has finished (i.e. once start returns)
and only permitted to do once (otherwise multiple recovered runtimes will share the same inner state).
If either one of these conditions is violated, this method will panic.
Trait Implementations§
Source§impl Clock for Context
 
impl Clock for Context
Source§fn current(&self) -> SystemTime
 
fn current(&self) -> SystemTime
Source§fn sleep(&self, duration: Duration) -> impl Future<Output = ()> + Send + 'static
 
fn sleep(&self, duration: Duration) -> impl Future<Output = ()> + Send + 'static
Source§fn sleep_until(
    &self,
    deadline: SystemTime,
) -> impl Future<Output = ()> + Send + 'static
 
fn sleep_until( &self, deadline: SystemTime, ) -> impl Future<Output = ()> + Send + 'static
Source§impl ReasonablyRealtime for Context
 
impl ReasonablyRealtime for Context
Source§fn reference_point(&self) -> Self::Instant
 
fn reference_point(&self) -> Self::Instant
Source§impl RngCore for Context
 
impl RngCore for Context
Source§fn fill_bytes(&mut self, dest: &mut [u8])
 
fn fill_bytes(&mut self, dest: &mut [u8])
dest with random data. Read moreSource§impl Spawner for Context
 
impl Spawner for Context
Source§fn spawn<F, T>(&self, label: &str, f: F) -> Handle<T> ⓘ
 
fn spawn<F, T>(&self, label: &str, f: F) -> Handle<T> ⓘ
Source§impl Storage<Blob> for Context
 
impl Storage<Blob> for Context
impl CryptoRng for Context
Auto Trait Implementations§
impl Freeze for Context
impl !RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
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
Source§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
Source§impl<T> CryptoRngCore for T
 
impl<T> CryptoRngCore for T
Source§fn as_rngcore(&mut self) -> &mut dyn RngCore
 
fn as_rngcore(&mut self) -> &mut dyn RngCore
RngCore trait object.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<R> Rng for R
 
impl<R> Rng for R
Source§fn gen<T>(&mut self) -> Twhere
    Standard: Distribution<T>,
 
fn gen<T>(&mut self) -> Twhere
    Standard: Distribution<T>,
Source§fn gen_range<T, R>(&mut self, range: R) -> Twhere
    T: SampleUniform,
    R: SampleRange<T>,
 
fn gen_range<T, R>(&mut self, range: R) -> Twhere
    T: SampleUniform,
    R: SampleRange<T>,
Source§fn sample<T, D>(&mut self, distr: D) -> Twhere
    D: Distribution<T>,
 
fn sample<T, D>(&mut self, distr: D) -> Twhere
    D: Distribution<T>,
Source§fn sample_iter<T, D>(self, distr: D) -> DistIter<D, Self, T>where
    D: Distribution<T>,
    Self: Sized,
 
fn sample_iter<T, D>(self, distr: D) -> DistIter<D, Self, T>where
    D: Distribution<T>,
    Self: Sized,
Source§fn gen_bool(&mut self, p: f64) -> bool
 
fn gen_bool(&mut self, p: f64) -> bool
p of being true. Read moreSource§fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool
 
fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool
numerator/denominator of being
true. I.e. gen_ratio(2, 3) has chance of 2 in 3, or about 67%, of
returning true. If numerator == denominator, then the returned value
is guaranteed to be true. If numerator == 0, then the returned
value is guaranteed to be false. Read more