Trait ReactorBehavior

Source
pub trait ReactorBehavior {
    // Required methods
    fn id(&self) -> ReactorId;
    fn react(
        &mut self,
        ctx: &mut ReactionCtx<'_, '_>,
        local_rid: LocalReactionId,
    );
    fn cleanup_tag(&mut self, ctx: &CleanupCtx);
}
Expand description

The trait used by the framework to interact with the reactor during runtime.

Importantly, it’s object-safe and has no type parameters or associated types. This allows us to wrap it into a Box<dyn ReactorBehavior>.

Required Methods§

Source

fn id(&self) -> ReactorId

The unique ID of this reactor. This is given by the framework upon construction.

Source

fn react(&mut self, ctx: &mut ReactionCtx<'_, '_>, local_rid: LocalReactionId)

Execute a single user-written reaction. Dispatches on the reaction id, and unpacks parameters, which are the reactor components declared as fields of this struct.

It must always be the case that local_rid < Self::MAX_REACTION_ID, where Self::MAX_REACTION_ID is defined by the assembly::ReactorInitializer, because of object safety.

Source

fn cleanup_tag(&mut self, ctx: &CleanupCtx)

Acknowledge that the given tag is done executing and free resources if need be.

Implementors§