Struct relm::EventStream

source ·
pub struct EventStream<MSG> { /* private fields */ }
Expand description

A stream of messages to be used for widget/signal communication and inter-widget communication. EventStream cannot be send to another thread. Use a Channel Sender instead.

Implementations§

source§

impl<MSG> EventStream<MSG>

source

pub fn new() -> Self

Create a new event stream.

source

pub fn close(&self)

Close the event stream, i.e. stop processing messages.

source

pub fn stream(&self) -> StreamHandle<MSG>

Synonym for downgrade().

source

pub fn downgrade(&self) -> StreamHandle<MSG>

Create a Clone-able EventStream handle.

source

pub fn emit(&self, event: MSG)

Send the event message to the stream and the observers.

source

pub fn lock(&self) -> Lock<MSG>

Lock the stream (don’t emit message) until the Lock goes out of scope.

source

pub fn observe<CALLBACK: Fn(&MSG) + 'static>(&self, callback: CALLBACK)

Add an observer to the event stream. This callback will be called every time a message is emmited.

source

pub fn set_callback<CALLBACK: FnMut(MSG) + 'static>(&self, callback: CALLBACK)

Add a callback to the event stream. This is the main callback and received a owned version of the message, in contrast to observe().

Trait Implementations§

source§

impl<MSG> Drop for EventStream<MSG>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<MSG> RefUnwindSafe for EventStream<MSG>where MSG: RefUnwindSafe,

§

impl<MSG> !Send for EventStream<MSG>

§

impl<MSG> !Sync for EventStream<MSG>

§

impl<MSG> Unpin for EventStream<MSG>

§

impl<MSG> UnwindSafe for EventStream<MSG>where MSG: RefUnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

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 Twhere U: TryFrom<T>,

§

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.