pub struct Context { /* private fields */ }Expand description
Runtime capabilities and supervision context for the current task.
Ordinary children run on the pool, including those spawned by dedicated and blocking tasks. Task factories run on their caller, while ordinary futures run on the pool and can move between its workers, as can resources and pending I/O and sleep futures.
Registrations stay on their original worker. Closing that worker causes unresolved I/O futures to fail and unresolved sleeps to panic when polled. Pool workers close only at shutdown, after every pool task has been dropped, while dedicated and blocking tasks may still run. Detached sync completion handles can be awaited on any thread.
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 + use<>
fn sleep( &self, duration: Duration, ) -> impl Future<Output = ()> + Send + 'static + use<>
Sleep for the given duration.
Source§fn sleep_until(
&self,
deadline: SystemTime,
) -> impl Future<Output = ()> + Send + 'static + use<>
fn sleep_until( &self, deadline: SystemTime, ) -> impl Future<Output = ()> + Send + 'static + use<>
Sleep until the given deadline.
Source§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 Spawner for Context
impl Spawner for Context
Source§fn spawn<F, Fut, T>(self, f: F) -> Handle<T> ⓘ
fn spawn<F, Fut, T>(self, f: F) -> Handle<T> ⓘ
Spawn a task with the current context. Read more
Source§async fn stop(self, value: i32, timeout: Option<Duration>) -> Result<(), Error>
async fn stop(self, value: i32, timeout: Option<Duration>) -> Result<(), Error>
Signals the runtime to stop execution and waits for all outstanding tasks
to perform any required cleanup and exit. Read more
Source§fn stopped(&self) -> Signal ⓘ
fn stopped(&self) -> Signal ⓘ
Returns an instance of a signal::Signal that resolves when Spawner::stop is called by
any task. 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_versioned(
&self,
partition: &str,
name: &[u8],
versions: RangeInclusive<BlobVersion>,
) -> Result<(Self::Blob, u64, BlobVersion), Error>
async fn open_versioned( &self, partition: &str, name: &[u8], versions: RangeInclusive<BlobVersion>, ) -> Result<(Self::Blob, u64, BlobVersion), Error>
Open an existing blob in a given partition or create a new one, returning
the blob and its length. Read more
Source§async fn remove(
&self,
partition: &str,
name: Option<&[u8]>,
) -> Result<(), Error>
async fn remove( &self, partition: &str, name: Option<&[u8]>, ) -> Result<(), Error>
Remove a blob from a given partition. Read more
Source§impl Strategizer for Context
impl Strategizer for Context
Source§impl Supervisor for Context
impl Supervisor for Context
impl TryCryptoRng for Context
Auto Trait Implementations§
impl !RefUnwindSafe for Context
impl !UnwindSafe for Context
impl Freeze for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<R> CryptoRng for R
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> ⓘ
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> MetricsExt for Twhere
T: Metrics,
impl<T> MetricsExt for Twhere
T: Metrics,
Source§fn counter<N: Into<String>, H: Into<String>>(&self, name: N, help: H) -> Counter
fn counter<N: Into<String>, H: Into<String>>(&self, name: N, help: H) -> Counter
Register a counter with the runtime.
Source§fn gauge<N: Into<String>, H: Into<String>>(&self, name: N, help: H) -> Gauge
fn gauge<N: Into<String>, H: Into<String>>(&self, name: N, help: H) -> Gauge
Register a gauge with the runtime.
Source§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,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<R> RngCore for Rwhere
R: Rng,
Source§impl<R> RngExt for R
impl<R> RngExt for R
Source§fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
fn random<T>(&mut self) -> Twhere
StandardUniform: Distribution<T>,
Return a random value via the
StandardUniform distribution. Read moreSource§fn random_iter<T>(self) -> Iter<StandardUniform, Self, T> ⓘ
fn random_iter<T>(self) -> Iter<StandardUniform, Self, T> ⓘ
Source§fn random_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn random_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 random_bool(&mut self, p: f64) -> bool
fn random_bool(&mut self, p: f64) -> bool
Return a bool with a probability
p of being true. Read moreSource§fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool
Return a bool with a probability of
numerator/denominator of being
true. Read moreSource§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) -> Iter<D, Self, T> ⓘwhere
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T> ⓘwhere
D: Distribution<T>,
Self: Sized,
Create an iterator that generates values using the given distribution. Read more