pub struct Context { /* private fields */ }
Expand description
Implementation of crate::Spawner, crate::Clock,
crate::Network, and crate::Storage for the tokio
runtime.
Trait Implementations§
Source§impl Clock for Context
impl Clock for Context
Source§fn current(&self) -> SystemTime
fn current(&self) -> SystemTime
Returns the current time.
Source§fn sleep(&self, duration: Duration) -> impl Future<Output = ()> + Send + 'static
fn sleep(&self, duration: Duration) -> impl Future<Output = ()> + Send + 'static
Sleep for the given duration.
Source§fn sleep_until(
&self,
deadline: SystemTime,
) -> impl Future<Output = ()> + Send + 'static
fn sleep_until( &self, deadline: SystemTime, ) -> impl Future<Output = ()> + Send + 'static
Sleep until the given deadline.
Source§impl Metrics for Context
impl Metrics for Context
Source§fn with_label(&self, label: &str) -> Self
fn with_label(&self, label: &str) -> Self
Create a new instance of
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
Returns a reference point at the start of an operation.
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])
Fill
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
Enqueue a task to be executed (without consuming the context). Read more
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> ⓘ
Enqueue a blocking task to be executed. Read more
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
Enqueue a blocking task to be executed (without consuming the context). Read more
Source§impl Storage for Context
impl Storage for Context
Source§type Blob = <Storage<Storage> as Storage>::Blob
type Blob = <Storage<Storage> as Storage>::Blob
The readable/writeable storage buffer that can be opened by this Storage.
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>
Open an existing blob in a given partition or create a new one, returning
the blob and its length. Read more
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
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<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
Upcast to an
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>
Converts
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>
Converts
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>,
Generate a random value in the given range. Read more
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>,
Sample a new value, using the given distribution. Read more
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,
Create an iterator that generates values using the given distribution. Read more
Source§fn gen_bool(&mut self, p: f64) -> bool
fn gen_bool(&mut self, p: f64) -> bool
Return a bool with a probability
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
Return a bool with a probability of
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