Struct eventador::Subscriber[][src]

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

A handle to receive events that were subscribed to from the event-bus.

The Subscriber will not receive intended events that were published to the event-bus before time of subscription. It will only receive intended events that are published after the time of subscription, as they will have a higher sequence number than the Subscriber's internal sequence value.

Example

Basic usage:

let eventbus = Eventador::new(4)?;

// subscribe first, before publishing!
let subscriber = eventbus.subscribe::<usize>();

let mut i: usize = 1234;
eventbus.publish(i);

let mut msg = subscriber.recv();
assert_eq!(i, *msg);

Implementations

impl<T: 'static> Subscriber<T> where
    T: Send
[src]

pub fn sequence(&self) -> u64[src]

Get the current internal sequence number for the Subscriber.

This sequence number signifies what events the Subscriber may have already read, and any events with a sequence value higher than this are events that are still unread.

pub fn recv<'b>(&self) -> EventRead<'b, T>[src]

Synchronously read an event of the correct type from the event-bus.

Example

Basic usage:

let eventbus = Eventador::new(4)?;
let subscriber = eventbus.subscribe::<usize>();

let mut i: usize = 1234;
eventbus.publish(i);

let mut msg = subscriber.recv();
assert_eq!(i, *msg);

Auto Trait Implementations

impl<T> !RefUnwindSafe for Subscriber<T>[src]

impl<T> Send for Subscriber<T> where
    T: Send
[src]

impl<T> Sync for Subscriber<T> where
    T: Sync
[src]

impl<T> Unpin for Subscriber<T> where
    T: Unpin
[src]

impl<T> !UnwindSafe for Subscriber<T>[src]

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> Pointable for T

type Init = T

The type for initializers.

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.