[−][src]Struct bottles::queue::Queue
A Queue of messages which are expected to be delivered to the corresponding subscribers along with a reference to a shared context value.
The Queue achieves its goal by enqueueing the awaiting messages in order to dispatch them
on demand by a call to the Queue::poll
method, which accepts the shared context mutable reference.
Methods
impl<T> Queue<T>
[src]
pub fn new() -> Self
[src]
Creates a new Queue
pub fn register<M: 'static>(&mut self, dispatcher: &mut Dispatcher)
[src]
Registers a new message value type to be possible to subscriber to and dispatch.
This is analogous to the Dispatcher::register()
method, but not only it registers the type
in the provided dispatcher
but also internally, to create a queue for the specified type.
pub fn subscribe<F, M>(&mut self, dispatcher: &mut Dispatcher, f: F) where
F: FnMut(&mut T, Rc<M>) + 'static,
M: 'static,
[src]
F: FnMut(&mut T, Rc<M>) + 'static,
M: 'static,
Subscribes the provide closure which takes exactly 2 arguments:
&mut T
context value
Rc<M>
the expected message type.
This is analogous to the Dispatcher::subscribe(callback)
method, but the provided callback will
be called only when Queue::poll(&mut context)
is called.
Implementation details
The subscriber
provided to the underlying dispatcher
is a simple closure which takes the
message and puts it in the Queue
's queue.
pub fn poll(&mut self, context: &mut T)
[src]
Dispatches all accumulated messages to the corresponding subscribers along with the provided mutable reference to a context value.
Auto Trait Implementations
impl<T> !RefUnwindSafe for Queue<T>
impl<T> !Send for Queue<T>
impl<T> !Sync for Queue<T>
impl<T> Unpin for Queue<T>
impl<T> !UnwindSafe for Queue<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>,