Skip to main content

Context

Struct Context 

Source
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

Source

pub fn auditor(&self) -> Arc<Auditor>

Get a reference to the Auditor.

Source

pub fn storage_audit(&self) -> [u8; 32]

Compute a Sha256 digest of all storage contents.

Source

pub fn storage_fault_config(&self) -> Arc<RwLock<FaultConfig>>

Access the storage fault configuration.

Changes to the returned FaultConfig take effect immediately for subsequent storage operations. This allows dynamically enabling or disabling fault injection during a test.

Source

pub fn resolver_register( &self, host: impl Into<String>, addrs: Option<Vec<IpAddr>>, )

Register a DNS mapping for a hostname.

If addrs is None, the mapping is removed. If addrs is Some, the mapping is added or updated.

Trait Implementations§

Source§

impl BufferPooler for Context

Source§

fn network_buffer_pool(&self) -> &BufferPool

Returns the network BufferPool.
Source§

fn storage_buffer_pool(&self) -> &BufferPool

Returns the storage BufferPool.
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§

fn timeout<F, T>( &self, duration: Duration, future: F, ) -> impl Future<Output = Result<T, Error>> + Send + '_
where F: Future<Output = T> + Send + 'static, T: Send + 'static,

Await a future with a timeout, returning Error::Timeout if it expires. Read more
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 Metrics for Context

Source§

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

Register a metric with the runtime. Read more
Source§

fn encode(&self) -> String

Encode all metrics into a buffer.
Source§

impl Network for Context

Source§

type Listener = <Network<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 Resolver for Context

Source§

async fn resolve(&self, host: &str) -> Result<Vec<IpAddr>, Error>

Resolve a hostname to IP addresses. Read more
Source§

impl Spawner for Context

Source§

fn dedicated(self) -> Self

Return a Spawner that runs the next task on a dedicated thread when the runtime supports it. Read more
Source§

fn shared(self, blocking: bool) -> Self

Return a Spawner that schedules the next task onto the runtime’s shared executor. Read more
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,

Spawn a task with the current 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<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<u16>, ) -> Result<(Self::Blob, u64, u16), 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§

fn open( &self, partition: &str, name: &[u8], ) -> impl Future<Output = Result<(Self::Blob, u64), Error>> + Send

Storage::open_versioned with DEFAULT_BLOB_VERSION as the only value in the versions range. The blob version is omitted from the return value.
Source§

impl Strategizer for Context

Spawning threads would be nondeterministic, so the pool has no background workers. The executor thread registers itself as its sole member and all work executes inline.

Rayon’s current-thread registration is permanent and per-OS-thread, so only one pool can ever execute work on the executor thread. Every request (including from a later runner on the same thread) returns a strategy on that single-threaded pool with its planning parallelism set independently. This controls adaptive decisions and manual partitioning hints while Rayon executes on the sole registered thread. The returned strategy is therefore tied to the executor thread.

Source§

fn strategy(&self, parallelism: NonZeroUsize) -> Rayon

Returns a new Rayon strategy with the requested parallelism. Read more
Source§

impl Supervisor for Context

Source§

fn child(&self, label: &'static str) -> Self

Create a named child context with a new supervision-tree node. Read more
Source§

fn with_attribute(self, key: &'static str, value: impl Display) -> Self

Add a key-value attribute to this context’s identity. Read more
Source§

fn name(&self) -> Name

Return the current label prefix and attributes.
Source§

impl TryCryptoRng for Context

Source§

impl TryRng for Context

Source§

type Error = Infallible

The type returned in the event of a RNG error. Read more
Source§

fn try_next_u32(&mut self) -> Result<u32, Self::Error>

Return the next random u32.
Source§

fn try_next_u64(&mut self) -> Result<u64, Self::Error>

Return the next random u64.
Source§

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

Fill dst entirely with random data.

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<R> CryptoRng for R
where R: TryCryptoRng<Error = Infallible> + ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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> MetricsExt for T
where T: Metrics,

Source§

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

Register a gauge with the runtime.
Source§

fn histogram<N: Into<String>, H: Into<String>, I>( &self, name: N, help: H, buckets: I, ) -> Histogram
where I: IntoIterator<Item = f64>,

Register a histogram with the runtime.
Source§

fn family<N, H, S, M>(&self, name: N, help: H) -> Registered<Family<S, M>>
where N: Into<String>, H: Into<String>, S: Clone + Hash + Eq, M: Default, Family<S, M>: Metric,

Register a metric family with the runtime.
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: Sized + 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: Sized + 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: TryRng<Error = Infallible> + ?Sized,

Source§

fn next_u32(&mut self) -> u32

Return the next random u32.
Source§

fn next_u64(&mut self) -> u64

Return the next random u64.
Source§

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

Fill dest with random data. Read more
Source§

impl<R> RngCore for R
where R: Rng,

Source§

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

Source§

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

Return a random value via the StandardUniform distribution. Read more
Source§

fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>

Return an iterator over random variates Read more
Source§

fn random_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 random_bool(&mut self, p: f64) -> bool

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

fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool

Return a bool with a probability of numerator/denominator of being true. 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) -> Iter<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,

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<R> TryRngCore for R
where R: TryRng,

Source§

type Error = <R as TryRng>::Error

👎Deprecated since 0.10.0:

use TryRng instead

Error type.
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