[][src]Struct sealrs::testkit::actors::test_probe::TestProbe

pub struct TestProbe { /* fields omitted */ }

Methods

impl TestProbe[src]

pub fn new(system: TSafe<TestLocalActorSystem>, name: Option<&str>) -> TestProbe[src]

Initialize new probe. This is internal construct, do not try use it directly

pub fn aref(&mut self) -> ActorRef[src]

Return internal actor reference

pub fn set_timeout(&mut self, timeout: Duration)[src]

Set default expects timeout

pub fn send(&mut self, target: &mut ActorRef, msg: Message)[src]

Send message to some actor

pub fn reply(&mut self, msg: Message)[src]

Reply to the last sender with specified message

pub fn expect_msg(
    &mut self,
    matcher: Box<dyn Fn(Message) -> bool + Send>
) -> Message
[src]

Expect a single message from an actor. Blocks called thread while message will be received or timeout was reached. Returns intercepted message instance.

Example

probe.expect_msg(type_matcher!(some_actor::SomeMsg));
let msg = probe.expect_msg(type_matcher!(some_actor::SomeMsgOther));

pub fn expect_msg_any_of(
    &mut self,
    matchers: Vec<Box<dyn Fn(Message) -> bool + Send>>
) -> Message
[src]

Expect an any message in the specified set from an actor. Blocks called thread while message will be received or timeout was reached. Returns intercepted messages list.

Example

probe.expect_msg_any_of(
    vec![
        type_matcher!(some_actor::SomeMsg0)),
        type_matcher!(some_actor::SomeMsg1)),
        type_matcher!(some_actor::SomeMsg2))
    ]
);

pub fn expect_msg_all_of(
    &mut self,
    matchers: Vec<Box<dyn Fn(Message) -> bool + Send>>
) -> Vec<Message>
[src]

Expect all messages in specified set from an actor. Order of messages is not not significant. Target message may be altered with some other messages. Test will passed, when all messages from the list, will be intercepted from input messages stream. Blocks called thread while message will be received or timeout was reached. Returns intercepted messages list.

Example

probe.expect_msg_all_of(
    vec![
        type_matcher!(some_actor::SomeMsg0)),
        type_matcher!(some_actor::SomeMsg1)),
        type_matcher!(some_actor::SomeMsg2))
    ]
);

pub fn expect_no_msg(&mut self, duration: Duration)[src]

Expect than no one actor do not send message to this probe in specified time duration

Example

probe.expect_no_msg(Duration::from_secs(1));

pub fn expect_terminated(&mut self, target: &ActorRef)[src]

Expect termination of the target. Probe must be watch it before cull this expector.

Example

 probe.watch(&target);
 // Some other code
 probe.expect_terminated(&target);

pub fn watch(&mut self, target: &ActorRef)[src]

Subscribe probe fot watching events of target

pub fn get_last_sender(&self) -> MutexGuard<ActorRef>[src]

Returns the sender of the last received message.

pub fn stop(&mut self)[src]

Stops the probe inner actor

Trait Implementations

impl Drop for TestProbe[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]