pub struct Msg(/* private fields */);
Expand description
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: SignedMessage = 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...
// get message signature
let sign = signature!();
ctx.tell(&sign, "A message containing reply").unwrap();
};
// 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!(ctx, "An answer message containing data.");
};
// We match a message that wasn't previously matched...
_: _ => ();
}
}
}
})
}).expect("Couldn't start the children group.");
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Msg
impl !RefUnwindSafe for Msg
impl Send for Msg
impl Sync for Msg
impl Unpin for Msg
impl !UnwindSafe for Msg
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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