Skip to main content

SimClusterReceiver

Struct SimClusterReceiver 

Source
pub struct SimClusterReceiver<T: Serialize + DeserializeOwned, O: Ordering, R: Retries>(/* private fields */);
Available on crate feature sim only.
Expand description

A receiver for an external cluster stream in a simulation.

Each received value is a (u32, T) tuple where the u32 is the raw cluster member ID that produced the value.

Implementations§

Source§

impl<T: Serialize + DeserializeOwned> SimClusterReceiver<T, TotalOrder, ExactlyOnce>

Source

pub fn next(&self, member_id: u32) -> impl use<'_, T> + Future<Output = T>

Receives the next value from a specific cluster member, waiting (and letting the scheduler run any pending simulation work) until one is available. If the simulation becomes quiescent without producing a value, the test fails.

This is safe to use in the middle of a test; to observe the absence of a value, use Self::try_next.

Source

pub async fn try_next(&self, member_id: u32) -> Option<T>

Receives the next value from a specific cluster member, or returns None if no more values can possibly arrive.

If answering requires forcing pending nondeterministic work to run, then afterwards, sending more input and then attempting to receive output will panic. Prefer Self::next when possible.

Source

pub async fn collect<C: Default + Extend<T>>(self, member_id: u32) -> C

Collects all remaining values from a specific cluster member into a collection, waiting until no more values can possibly arrive.

If this has to force pending nondeterministic work to run, it should be the last observation of the test; see SimReceiver::collect.

Source§

impl<T: Serialize + DeserializeOwned> SimClusterReceiver<T, NoOrder, ExactlyOnce>

Source

pub fn collect_n_sorted<C: Default + Extend<T> + AsMut<[T]>>( &self, member_id: u32, n: usize, ) -> impl use<'_, T, C> + Future<Output = C>
where T: Ord,

Receives the next n values from a specific cluster member, sorted, waiting (and letting the scheduler run any pending simulation work) until they are available. If the simulation becomes quiescent before n values arrive, the test fails.

Like SimReceiver::next, this is safe to use in the middle of a test.

Source

pub async fn collect_sorted<C: Default + Extend<T> + AsMut<[T]>>( self, member_id: u32, ) -> C
where T: Ord,

Collects all remaining values from a specific cluster member, sorted, waiting until no more values can possibly arrive.

If this has to force pending nondeterministic work to run, it should be the last observation of the test; see SimReceiver::collect.

Trait Implementations§

Source§

impl<T: Serialize + DeserializeOwned, O: Ordering, R: Retries> Clone for SimClusterReceiver<T, O, R>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Serialize + DeserializeOwned, O: Ordering, R: Retries> Copy for SimClusterReceiver<T, O, R>

Auto Trait Implementations§

§

impl<T, O, R> Freeze for SimClusterReceiver<T, O, R>

§

impl<T, O, R> RefUnwindSafe for SimClusterReceiver<T, O, R>

§

impl<T, O, R> Send for SimClusterReceiver<T, O, R>
where T: Send, O: Send, R: Send,

§

impl<T, O, R> Sync for SimClusterReceiver<T, O, R>
where T: Sync, O: Sync, R: Sync,

§

impl<T, O, R> Unpin for SimClusterReceiver<T, O, R>
where T: Unpin, O: Unpin, R: Unpin,

§

impl<T, O, R> UnsafeUnpin for SimClusterReceiver<T, O, R>

§

impl<T, O, R> UnwindSafe for SimClusterReceiver<T, O, R>
where T: UnwindSafe, O: UnwindSafe, R: UnwindSafe,

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
§

impl<T> AsOut<T> for T
where T: Copy,

§

fn as_out(&mut self) -> Out<'_, T>

Returns an out reference to self.
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
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> ToSinkBuild for T

Source§

fn iter_to_sink_build(self) -> SendIterBuild<Self>
where Self: Sized + Iterator,

Starts a SinkBuild adaptor chain to send all items from self as an Iterator.
Source§

fn stream_to_sink_build(self) -> SendStreamBuild<Self>
where Self: Sized + Stream,

Starts a SinkBuild adaptor chain to send all items from self as a [Stream].
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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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