Struct eventador::Subscriber[][src]

pub struct Subscriber<'a, 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().unwrap();
assert_eq!(i, *msg);

Implementations

impl<'a, T> Subscriber<'a, T> where
    T: 'static + 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) -> Option<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().unwrap();
assert_eq!(i, *msg);

Auto Trait Implementations

impl<'a, T> !RefUnwindSafe for Subscriber<'a, T>[src]

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

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

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

impl<'a, T> !UnwindSafe for Subscriber<'a, 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[src]

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.