[][src]Struct bastion::message::Msg

pub struct Msg(_);

A message returned by BastionContext::recv or BastionContext::try_recv that should be passed to the msg! macro to try to match what its real type is.

Example

Bastion::children(|children| {
    children.with_exec(|ctx: BastionContext| {
        async move {
            loop {
                let msg: Msg = ctx.recv().await?;
                msg! { msg,
                    // We match a broadcasted `&'static str`s...
                    ref msg: &'static str => {
                        // Note that `msg` will actually be a `&&'static str`.
                        assert_eq!(msg, &"A message containing data.");

                        // Handle the message...
                    };
                    // We match a `&'static str`s "told" to this child...
                    msg: &'static str => {
                        assert_eq!(msg, "A message containing data.");
                        // Handle the message...
                    };
                    // We match a `&'static str`s "asked" to this child...
                    msg: &'static str =!> {
                        assert_eq!(msg, "A message containing data.");
                        // Handle the message...

                        // ...and eventually answer to it...
                        answer!("An answer message containing data.");
                    };
                    // We match a message that wasn't previously matched...
                    _: _ => ();
                }
            }
        }
    })
}).expect("Couldn't start the children group.");

Trait Implementations

impl Debug for Msg[src]

Auto Trait Implementations

impl Send for Msg

impl Sync for Msg

impl Unpin for Msg

impl !UnwindSafe for Msg

impl !RefUnwindSafe for Msg

Blanket Implementations

impl<T> Message for T where
    T: Any + Send + Sync + Debug
[src]

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

impl<T> From<T> for 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> Borrow<T> for T where
    T: ?Sized
[src]

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

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

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