[−][src]Struct event_feed::Feed
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]
Evt: Send,
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]
F: FnMut() -> Evt,
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]
Evt: Send + Clone,
impl<Evt> Feed<Evt> where
Evt: Send + Default,
[src]
Evt: Send + Default,
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]
Evt: Send,
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.
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<Evt: Debug> Debug for Feed<Evt> where
Evt: Send,
[src]
Evt: Send,
impl<Evt> Default for Feed<Evt> where
Evt: Send,
[src]
Evt: Send,
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]
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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>,