pub struct Host<T> {
pub tasks: Vec<JoinHandle<Option<u8>>>,
/* private fields */
}Expand description
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§
Source§impl<T: Sync + Send + 'static> Host<T>
impl<T: Sync + Send + 'static> Host<T>
Sourcepub const DEFAULT_CHANNEL_CAPACITY: usize = 4usize
pub const DEFAULT_CHANNEL_CAPACITY: usize = 4usize
By default, plugins will communicate with the host using a queue capable of holding this many Messages.
pub fn new() -> Self
Sourcepub fn send(&mut self, message: impl Into<Message<T>>)
pub fn send(&mut self, message: impl Into<Message<T>>)
Sends a message to all the attached Plugins.
Sourcepub fn attach(&mut self, plugin: impl Plugin<T>)
pub fn attach(&mut self, plugin: impl Plugin<T>)
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.
Sourcepub fn attach_with_capacity(&mut self, plugin: impl Plugin<T>, capacity: usize)
pub fn attach_with_capacity(&mut self, plugin: impl Plugin<T>, capacity: usize)
Like attach, but allows you to choose your own channel capacity.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Host<T>
impl<T> !RefUnwindSafe for Host<T>
impl<T> Send for Host<T>
impl<T> Sync for Host<T>
impl<T> Unpin for Host<T>
impl<T> !UnwindSafe for Host<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more