[][src]Struct bottles::queue::Queue

pub struct Queue<T> { /* fields omitted */ }

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]

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]

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.