Struct relm::Component

source ·
pub struct Component<WIDGET: Widget> { /* private fields */ }
Expand description

Widget that was added by the ContainerWidget::add_widget() method.

Warning

You must keep your components as long as you want them to send/receive events. Common practice is to store Components in the Widget struct (see the communication example). The #[widget] attribute takes care of storing them in the struct automatically (see the communication-attribute example).

Implementations§

source§

impl<WIDGET: Widget> Component<WIDGET>

source

pub fn emit(&self, msg: WIDGET::Msg)

Emit a message of the widget stream.

source

pub fn stream(&self) -> StreamHandle<WIDGET::Msg>

Get the event stream of the component. This is used internally by the library.

source

pub fn owned_stream(&self) -> &EventStream<WIDGET::Msg>

Get the event stream of the component. This is used internally by the library.

source

pub fn widget(&self) -> &WIDGET::Root

Get the widget of the component.

Auto Trait Implementations§

§

impl<WIDGET> RefUnwindSafe for Component<WIDGET>where <WIDGET as Update>::Msg: RefUnwindSafe, <WIDGET as Widget>::Root: RefUnwindSafe,

§

impl<WIDGET> !Send for Component<WIDGET>

§

impl<WIDGET> !Sync for Component<WIDGET>

§

impl<WIDGET> Unpin for Component<WIDGET>where <WIDGET as Widget>::Root: Unpin,

§

impl<WIDGET> UnwindSafe for Component<WIDGET>where <WIDGET as Update>::Msg: RefUnwindSafe, <WIDGET as Widget>::Root: UnwindSafe,

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.