[][src]Struct event_feed::Feed

pub struct Feed<Evt> where
    Evt: Send
{ /* fields omitted */ }

An event feed — the source of events in a feed-based event system.

Feeds are the source of readers, which are subscibers of the feed, capable of recieving the events from the feed.

Implementations

impl<Evt> Feed<Evt> where
    Evt: Send
[src]

pub fn new() -> Self[src]

Creates a new feed without any readers.

If you expect a certain number of readers, use with_reader_capacity.

pub fn with_reader_capacity(capacity: usize) -> Self[src]

Creates a new feed with internal storage allocated to be able to send to the specified amount of readers without reallocation.

If you know in advance how many readers you will have, use this method. Otherwise, use new for simplicity.

pub fn add_reader(&mut self) -> Arc<Reader<Evt>>[src]

Adds a new reader to the feed and returns it.

The resulting structure can be freely sent and shared over threads.

pub fn send_with<F>(&self, f: F) where
    F: FnMut() -> Evt, 
[src]

Sends an event to each reader by calling the specified closure once for each event.

If your type implements Clone, simply using send would be more idiomatic.

pub fn remove_dangling_readers(&mut self)[src]

Removes references to dropped readers in order to release memory allocated for them and speed up calls to methods which send events.

impl<Evt> Feed<Evt> where
    Evt: Send + Clone
[src]

pub fn send(&self, event: Evt)[src]

Sends the specified event to each reader by cloning it.

impl<Evt> Feed<Evt> where
    Evt: Send + Default
[src]

pub fn send_default(&self)[src]

Sends the default value of the event.

The Default implementation for the event type is called once per reader, even if it implements Clone.

Trait Implementations

impl<Evt> Clone for Feed<Evt> where
    Evt: Send
[src]

fn clone(&self) -> Self[src]

Clones the feed by creating a new feed which sends events to the same readers. The two feeds exist independently, i.e. adding a new reader to one of them will not modify another.

impl<Evt: Debug> Debug for Feed<Evt> where
    Evt: Send
[src]

impl<Evt> Default for Feed<Evt> where
    Evt: Send
[src]

Auto Trait Implementations

impl<Evt> !RefUnwindSafe for Feed<Evt>

impl<Evt> Send for Feed<Evt>

impl<Evt> Sync for Feed<Evt>

impl<Evt> Unpin for Feed<Evt>

impl<Evt> !UnwindSafe for Feed<Evt>

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.