[−][src]Struct actix_mock_helper::MockActorSequence
A mock for a sequence of messages sent to the actor Example:
struct FakeActor; impl Actor for FakeActor { type Context = actix::Context<Self>; } struct Msg1; struct Msg2; impl Message for Msg1 { type Result = i32; } impl Message for Msg2 { type Result = bool; } #[actix_rt::main] async fn main() { let mock_actor = MockActorSequence::new() .msg(|_m: &Msg1| 5) // you can access the message sent. .msg::<Msg2, _>(|_m| true) // alternate syntax to specify the message type .build::<FakeActor>(); assert_eq!(mock_actor.send(Msg1).await.unwrap(), 5); assert_eq!(mock_actor.send(Msg2).await.unwrap(), true); }
Implementations
impl MockActorSequence
[src]
pub fn new() -> Self
[src]
pub fn msg<Msg: Message, Cb>(self, cb: Cb) -> Self where
Msg: 'static,
Cb: FnMut(&Msg) -> Msg::Result,
Cb: 'static,
[src]
Msg: 'static,
Cb: FnMut(&Msg) -> Msg::Result,
Cb: 'static,
Add another message to be expected, and return the result of the callback. The type of the message is checked at runtime against the expectation, and the message itself is passed to the callback so that it can be used to build the result
pub fn build<A: Actor>(self) -> Addr<Mocker<A>>
[src]
Fnalize the sequence and build the actor. Returns an Addr
to the actor.
Must provide the actor type
Auto Trait Implementations
impl !RefUnwindSafe for MockActorSequence
impl !Send for MockActorSequence
impl !Sync for MockActorSequence
impl Unpin for MockActorSequence
impl !UnwindSafe for MockActorSequence
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,