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
pub fn new(cfg: Config) -> Self
Sourcepub fn recover(self) -> Self
pub fn recover(self) -> Self
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.
pub fn auditor(&self) -> &Auditor
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 Metrics for Context
impl Metrics for Context
Source§fn with_label(&self, label: &str) -> Self
fn with_label(&self, label: &str) -> Self
Metrics
with the given label appended to the end
of the current Metrics
label. Read moreSource§impl Network for Context
impl Network for Context
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_ref<F, T>(&mut self) -> impl FnOnce(F) -> Handle<T> + 'static
fn spawn_ref<F, T>(&mut self) -> impl FnOnce(F) -> Handle<T> + 'static
Source§fn spawn_blocking<F, T>(self, dedicated: bool, f: F) -> Handle<T> ⓘ
fn spawn_blocking<F, T>(self, dedicated: bool, f: F) -> Handle<T> ⓘ
Source§fn spawn_blocking_ref<F, T>(
&mut self,
dedicated: bool,
) -> impl FnOnce(F) -> Handle<T> + 'static
fn spawn_blocking_ref<F, T>( &mut self, dedicated: bool, ) -> impl FnOnce(F) -> Handle<T> + 'static
Source§impl Storage for Context
impl Storage for Context
Source§type Blob = <Storage<Storage<Storage>> as Storage>::Blob
type Blob = <Storage<Storage<Storage>> as Storage>::Blob
Source§async fn open(
&self,
partition: &str,
name: &[u8],
) -> Result<(Self::Blob, u64), Error>
async fn open( &self, partition: &str, name: &[u8], ) -> Result<(Self::Blob, u64), Error>
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
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