Skip to main content

EventChannel

Struct EventChannel 

Source
pub struct EventChannel<T: 'static> { /* private fields */ }
Expand description

The producing half of an EventStream.

A service that receives events from outside the composition — a platform callback, a worker thread, a socket — publishes through a channel, and every pending collector is woken. This is the shape that replaces “register an observer, then drain a queue” everywhere in the framework.

Implementations§

Source§

impl<T: 'static> EventChannel<T>

Source

pub fn new() -> Self

Creates an open channel.

Source

pub fn stream(&self) -> EventStream<T>

The consuming half, handed to collectors.

Source

pub fn send(&self, event: T)

Publishes one event and wakes every pending collector.

Source

pub fn close(&self)

Ends the stream. Collectors drain what is queued and then finish.

Source

pub fn is_closed(&self) -> bool

Whether the channel has been closed.

Source

pub fn pending(&self) -> usize

How many events are queued but not yet taken.

Trait Implementations§

Source§

impl<T: 'static> Default for EventChannel<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for EventChannel<T>

§

impl<T> !Send for EventChannel<T>

§

impl<T> !Sync for EventChannel<T>

§

impl<T> !UnwindSafe for EventChannel<T>

§

impl<T> Freeze for EventChannel<T>
where Rc<ChannelShared<T>>: Freeze,

§

impl<T> Unpin for EventChannel<T>
where Rc<ChannelShared<T>>: Unpin,

§

impl<T> UnsafeUnpin for EventChannel<T>
where Rc<ChannelShared<T>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.