Skip to main content

Root

Struct Root 

Source
pub struct Root<T: Component> { /* private fields */ }
Expand description

Helper to run a root component.

Implementations§

Source§

impl<T: Component> Root<T>

Source

pub async fn init<'a>(init: impl Into<T::Init<'a>>) -> Result<Self, T::Error>

Create a new root component.

Source

pub fn post(&mut self, message: T::Message)

Post message to the component.

Source

pub async fn emit(&mut self, message: T::Message) -> Result<bool, T::Error>

Emit message to the component.

Source

pub fn sender(&self) -> &ComponentSender<T>

Get the sender of the component.

Source

pub fn into_child(self) -> Child<T>

Convert the root component into a child component.

Source

pub fn run( &mut self, ) -> impl Stream<Item = RunEvent<T::Event, T::Error>> + use<'_, T>

Run the component, and yield its events.

Source§

impl<T: Component + 'static> Root<T>

Source

pub fn into_boxed(self) -> Root<BoxComponent<T::Message, T::Event, T::Error>>

Box the component.

Auto Trait Implementations§

§

impl<T> Freeze for Root<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Root<T>
where T: RefUnwindSafe,

§

impl<T> Send for Root<T>
where T: Send, <T as Component>::Message: Send, <T as Component>::Event: Send,

§

impl<T> Sync for Root<T>
where T: Sync, <T as Component>::Message: Send, <T as Component>::Event: Send,

§

impl<T> Unpin for Root<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Root<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for Root<T>
where T: UnwindSafe,

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<Src, Dest> IntoTuple<Dest> for Src
where Dest: FromTuple<Src>,

Source§

fn into_tuple(self) -> Dest

Source§

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

Source§

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 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.