Context

Struct Context 

Source
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

Source§

fn current(&self) -> SystemTime

Returns the current time.
Source§

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

Sleep until the given deadline.
Source§

impl Clock for Context

Source§

type Instant = SystemTime

A measurement of a monotonically increasing clock.
Source§

fn now(&self) -> Self::Instant

Returns a measurement of the clock.
Source§

impl Clone for Context

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Metrics for Context

Source§

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 more
Source§

fn label(&self) -> String

Get the current label of the context.
Source§

fn register<N: Into<String>, H: Into<String>>( &self, name: N, help: H, metric: impl Metric, )

Register a metric with the runtime. Read more
Source§

fn encode(&self) -> String

Encode all metrics into a buffer.
Source§

fn scoped_label(&self, label: &str) -> String

Prefix the given label with the current context’s label. Read more
Source§

impl Network for Context

Source§

type Listener = <Network<Network> as Network>::Listener

The type of Listener that’s returned when binding to a socket. Accepting a connection returns a Sink and Stream which are defined by the Listener and used to send and receive data over the connection.
Source§

async fn bind(&self, socket: SocketAddr) -> Result<Self::Listener, Error>

Bind to the given socket address.
Source§

async fn dial( &self, socket: SocketAddr, ) -> Result<(SinkOf<Self>, StreamOf<Self>), Error>

Dial the given socket address.
Source§

impl ReasonablyRealtime for Context

Source§

fn reference_point(&self) -> Self::Instant

Returns a reference point at the start of an operation.
Source§

impl RngCore for Context

Source§

fn next_u32(&mut self) -> u32

Return the next random u32. Read more
Source§

fn next_u64(&mut self) -> u64

Return the next random u64. Read more
Source§

fn fill_bytes(&mut self, dest: &mut [u8])

Fill dest with random data. Read more
Source§

fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error>

Fill dest entirely with random data. Read more
Source§

impl Spawner for Context

Source§

fn spawn<F, Fut, T>(self, f: F) -> Handle<T>
where F: FnOnce(Self) -> Fut + Send + 'static, Fut: Future<Output = T> + Send + 'static, T: Send + 'static,

Enqueue a task to be executed. Read more
Source§

fn spawn_ref<F, T>(&mut self) -> impl FnOnce(F) -> Handle<T> + 'static
where F: Future<Output = T> + Send + 'static, T: Send + '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>
where F: FnOnce(Self) -> T + Send + 'static, T: Send + 'static,

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
where F: FnOnce() -> T + Send + 'static, T: Send + 'static,

Enqueue a blocking task to be executed (without consuming the context). Read more
Source§

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

Returns an instance of a signal::Signal that resolves when Spawner::stop is called by any task. Read more
Source§

impl Storage for Context

Source§

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>

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>

Remove a blob from a given partition. Read more
Source§

async fn scan(&self, partition: &str) -> Result<Vec<Vec<u8>>, Error>

Return all blobs in a given partition.
Source§

impl CryptoRng for Context

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> CryptoRngCore for T
where T: CryptoRng + RngCore,

Source§

fn as_rngcore(&mut self) -> &mut dyn RngCore

Upcast to an RngCore trait object.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<R> Rng for R
where R: RngCore + ?Sized,

Source§

fn gen<T>(&mut self) -> T

Return a random value supporting the Standard distribution. Read more
Source§

fn gen_range<T, R>(&mut self, range: R) -> T
where T: SampleUniform, R: SampleRange<T>,

Generate a random value in the given range. Read more
Source§

fn sample<T, D>(&mut self, distr: D) -> T
where 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,

Create an iterator that generates values using the given distribution. Read more
Source§

fn fill<T>(&mut self, dest: &mut T)
where T: Fill + ?Sized,

Fill any type implementing Fill with random data Read more
Source§

fn try_fill<T>(&mut self, dest: &mut T) -> Result<(), Error>
where T: Fill + ?Sized,

Fill any type implementing Fill with random data Read more
Source§

fn gen_bool(&mut self, p: f64) -> bool

Return a bool with a probability p of being true. Read more
Source§

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,