Trait Engine

Source
pub trait Engine {
    type Writer;
    type Reader;
    type Channel: Send + Sync + Clone;

    // Required methods
    fn schedule<B: Block<Writer = Self::Writer, Reader = Self::Reader> + 'static>(
        &mut self,
        block: B,
    );
    fn load_blocks_and_links(
        &mut self,
        blocks: &[BlockData],
        links: &[LinkData],
    ) -> Result<()>;
    async fn run(&mut self);
    fn create_message_channel(
        &mut self,
        sender_id: Uuid,
        sender_channel: Self::Channel,
    ) -> Self::Channel;
}
Expand description

Specifies the interface for an engine that implements the block execution logic.

Required Associated Types§

Source

type Writer

The transmission type of the blocks

Source

type Reader

The reception type of the blocks

Source

type Channel: Send + Sync + Clone

The type used to send messages to/from this engine.

Required Methods§

Source

fn schedule<B: Block<Writer = Self::Writer, Reader = Self::Reader> + 'static>( &mut self, block: B, )

Schedule a block to be executed by this engine. This operation can be performed while the engine is running.

Load the blocks and links into the engine. This operation should be performed before the engine is run.

Source

async fn run(&mut self)

Runs the event loop of this engine an execute the blocks that where scheduled

Source

fn create_message_channel( &mut self, sender_id: Uuid, sender_channel: Self::Channel, ) -> Self::Channel

Get a handle to this engines messaging system so external systems can communicate with this engine once the engine will run.

§Arguments
  • sender_id The sender unique id.
  • sender_channel The sender chanel to send notifications from the engine.
§Returns

A sender chanel that is used to send messages to the engine.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§