[−][src]Struct message_plugins::std_runtime::Host
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 JoinHandle
s 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 Message
s.
pub fn send(&mut self, message: impl Into<Message<T>>)
[src]
Sends a message to all the attached Plugin
s.
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
Auto Trait Implementations
impl<T> !RefUnwindSafe for Host<T>
impl<T> Send for Host<T> where
T: Send + Sync,
T: Send + Sync,
impl<T> Sync for Host<T> where
T: Send + Sync,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,