Skip to main content

TestProbe

Struct TestProbe 

Source
pub struct TestProbe<M: Send + 'static> { /* private fields */ }

Implementations§

Source§

impl<M: Send + 'static> TestProbe<M>

Source

pub fn new(name: &str) -> Self

Source

pub fn actor_ref(&self) -> &ActorRef<M>

Source

pub async fn expect_msg( &mut self, timeout: Duration, ) -> Result<M, TestProbeError>

Wait for a single message.

Source

pub async fn expect_msg_pf<F>( &mut self, timeout: Duration, pred: F, ) -> Result<M, TestProbeError>
where F: FnMut(&M) -> bool,

Wait for a message that matches the given predicate.

Source

pub async fn expect_no_msg( &mut self, timeout: Duration, ) -> Result<(), TestProbeError>

Assert that no message arrives within the given timeout.

Source

pub async fn expect_msg_class<T, F>( &mut self, timeout: Duration, extract: F, ) -> Result<T, TestProbeError>
where F: FnOnce(M) -> Option<T>,

Wait for a message and assert it matches the variant returned by extract.where T selects a sub-variant of the message enum. The extract closure returns Some(payload) for the desired variant.

Source

pub async fn receive_n( &mut self, n: usize, timeout: Duration, ) -> Result<Vec<M>, TestProbeError>

Receive exactly n messages or return TestProbeError::Timeout if timeout elapses before they all arrive.

Source

pub async fn receive_while<F>( &mut self, timeout: Duration, pred: F, ) -> Result<Vec<M>, TestProbeError>
where F: FnMut(&M) -> bool,

Receive messages while pred returns true, stopping at the first message for which pred returns false (that message is discarded).

Source

pub async fn fish_for_message<F>( &mut self, timeout: Duration, pred: F, ) -> Result<M, TestProbeError>
where F: FnMut(&M) -> bool,

Drain messages until one matches pred. Discards mismatches.

Source

pub async fn expect_all_of( &mut self, timeout: Duration, expected: Vec<M>, ) -> Result<(), TestProbeError>
where M: PartialEq + Debug,

Receive expected.len() messages and assert that the multi-set of received messages equals expected (order-insensitive).

Source

pub async fn expect_msg_eq( &mut self, timeout: Duration, expected: M, ) -> Result<M, TestProbeError>
where M: PartialEq + Debug,

Wait for a message and assert it equals expected. ExpectMsg<T>(T expected).

Source

pub async fn expect_msg_all_of_in_order( &mut self, timeout: Duration, expected: Vec<M>, ) -> Result<(), TestProbeError>
where M: PartialEq + Debug,

Receive n messages, asserting they appear in the exact order of expected.with sequential matching semantics.

Auto Trait Implementations§

§

impl<M> Freeze for TestProbe<M>

§

impl<M> !RefUnwindSafe for TestProbe<M>

§

impl<M> Send for TestProbe<M>

§

impl<M> Sync for TestProbe<M>

§

impl<M> Unpin for TestProbe<M>

§

impl<M> UnsafeUnpin for TestProbe<M>

§

impl<M> !UnwindSafe for TestProbe<M>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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<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> Extension for T
where T: Any + Send + Sync,