#[behavior]Expand description
Generate Behavior wiring for an inherent impl with an exact receive
method and an optional exact init method. When omitted, initialization is
the explicit empty transition: no sends, no creations, and Continue.
Invalid receivers are rejected at compile time.
ⓘ
use behavior::{Actions, Delivery, MailAddr, Never, NoBirths};
struct Invalid;
#[behavior::behavior(
addr = MailAddr,
message = u8,
sends = Vec<Never>,
births = NoBirths,
error = Never,
)]
impl Invalid {
fn init(&self) -> behavior::Acted<MailAddr, Never, Vec<Never>, NoBirths, Never> {
Ok(Actions::cont())
}
fn receive(&mut self, _: MailAddr, _: u8) -> behavior::Acted<MailAddr, Never, Vec<Never>, NoBirths, Never> {
Ok(Actions::cont())
}
}Missing receive methods are rejected by the macro itself:
ⓘ
use behavior::{Actions, Delivery, MailAddr, Never, NoBirths};
struct Missing;
#[behavior::behavior(
addr = MailAddr,
message = u8,
sends = Vec<Never>,
births = NoBirths,
error = Never,
)]
impl Missing {
}Async behavior methods cannot introduce an erased or alternate execution path:
ⓘ
use behavior::{Actions, Delivery, MailAddr, Never, NoBirths};
struct Async;
#[behavior::behavior(
addr = MailAddr,
message = u8,
sends = Vec<Never>,
births = NoBirths,
error = Never,
)]
impl Async {
async fn init(&mut self, _: crate::InitializationTurn) -> behavior::Acted<MailAddr, Never, Vec<Never>, NoBirths, Never> {
Ok(Actions::cont())
}
fn receive(&mut self, _: MailAddr, _: u8) -> behavior::Acted<MailAddr, Never, Vec<Never>, NoBirths, Never> {
Ok(Actions::cont())
}
}Generate the mechanical Behavior implementation for a normal inherent
impl containing receive(&mut self, from, message) and, optionally,
init(&mut self). Omitting init selects the behavior algebra’s empty
initialization transition. The original impl and methods are preserved
unchanged.