[][src]Struct message_plugins::std_runtime::Host

pub struct Host<T> {
    pub tasks: Vec<JoinHandle<Option<u8>>>,
    // some fields omitted
}

Meant as the main way of sending commands to plugins. A structure that holds the input ends of the queues to each plugin, as well as the JoinHandles to their tasks.

Fields

tasks: Vec<JoinHandle<Option<u8>>>

Implementations

impl<T: Sync + Send + 'static> Host<T>[src]

pub fn new() -> Self[src]

pub const DEFAULT_CHANNEL_CAPACITY: usize[src]

By default, plugins will communicate with the host using a queue capable of holding this many Messages.

pub fn send(&mut self, message: impl Into<Message<T>>)[src]

Sends a message to all the attached Plugins.

pub fn attach(&mut self, plugin: impl Plugin<T>)[src]

Enables a Plugin by attaching it to the Host: a channel is built, the input is given to the host; a task running the Plugin's handle_message method on every Message sent over the channel is spawned, and the JoinHandle to this task is added to the host's handles.

pub fn attach_with_capacity(&mut self, plugin: impl Plugin<T>, capacity: usize)[src]

Like attach, but allows you to choose your own channel capacity.

pub fn end(&mut self) -> Vec<Result<Option<u8>>>[src]

Drops every channel end, closing them, then waits for all plugins to finish processing the remaining messages.

Trait Implementations

impl<T> Drop for Host<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Host<T>

impl<T> Send for Host<T> where
    T: Send + Sync

impl<T> Sync for Host<T> where
    T: Send + Sync

impl<T> Unpin for Host<T>

impl<T> !UnwindSafe for Host<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.