Macro assert_behaves

Source
macro_rules! assert_behaves {
    ($ty:ty as $behavior:ty) => { ... };
}
Expand description

Check if the actor behaves-as the a given behavior (defined by [behavior!]).


// First, define a behavior, based on handling a single message type `()`.
hyperactor::behavior!(UnitBehavior, ());

#[derive(hyperactor::Actor, Debug, Default)]
struct MyActor;

#[async_trait::async_trait]
impl hyperactor::Handler<()> for MyActor {
    async fn handle(
        &mut self,
        _cx: &hyperactor::Context<Self>,
        _message: (),
    ) -> Result<(), anyhow::Error> {
        // no-op
        Ok(())
    }
}

hyperactor::assert_behaves!(MyActor as UnitBehavior);