Struct sauron_core::dom::cmd::Cmd

source ·
pub struct Cmd<APP, MSG>where
    MSG: 'static,{
    pub commands: Vec<Box<dyn FnOnce(Program<APP, MSG>)>>,
    /* private fields */
}
Expand description

Cmd is a command to be executed by the system. This is returned at the init function of a component and is executed right after instantiation of that component. Cmd required a DSP object which is the Program as an argument The emit function is called with the program argument. The callback is supplied with the program an is then executed/emitted.

Fields§

§commands: Vec<Box<dyn FnOnce(Program<APP, MSG>)>>

the functions that would be executed when this Cmd is emited

Implementations§

source§

impl<APP, MSG> Cmd<APP, MSG>where MSG: 'static, APP: Application<MSG> + 'static,

source

pub fn new<F>(f: F) -> Selfwhere F: FnOnce(Program<APP, MSG>) + 'static,

creates a new Cmd from a function

source

pub fn batch(cmds: impl IntoIterator<Item = Self>) -> Self

When you need the runtime to perform couple of commands, you can batch then together.

source

pub fn push(&mut self, cmd: Self)

Add a cmd

source

pub fn append(&mut self, cmds: impl IntoIterator<Item = Self>)

Append more cmd into this cmd and return self

source

pub fn none() -> Self

Tell the runtime that there are no commands.

source

pub fn should_update_view(self, should_update_view: bool) -> Self

Modify the Cmd such that whether or not it will update the view set by should_update_view when the cmd is executed in the program

source

pub fn no_render(self) -> Self

Modify the command such that it will not do an update on the view when it is executed.

source

pub fn measure(self) -> Self

Modify the command such that it will log measurement when it is executed

source

pub fn measure_with_name(self, name: &str) -> Self

Modify the Cmd such that it will log a measuregment when it is executed The measurement_name is set to distinguish the measurements from each other.

source

pub fn emit(self, program: &Program<APP, MSG>)

Executes the Cmd

source

pub fn batch_msg(msg_list: impl IntoIterator<Item = MSG>) -> Self

Tell the runtime to execute subsequent update of the App with the message list. A single call to update the view is then executed thereafter.

Trait Implementations§

source§

impl<APP, MSG> From<Effects<MSG, ()>> for Cmd<APP, MSG>where MSG: 'static, APP: Application<MSG> + 'static,

source§

fn from(effects: Effects<MSG, ()>) -> Self

Convert Effects that has only follow ups

source§

impl<APP, MSG> From<Vec<Effects<MSG, ()>, Global>> for Cmd<APP, MSG>where MSG: 'static, APP: Application<MSG> + 'static,

source§

fn from(effects: Vec<Effects<MSG, ()>>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<APP, MSG> !RefUnwindSafe for Cmd<APP, MSG>

§

impl<APP, MSG> !Send for Cmd<APP, MSG>

§

impl<APP, MSG> !Sync for Cmd<APP, MSG>

§

impl<APP, MSG> Unpin for Cmd<APP, MSG>

§

impl<APP, MSG> !UnwindSafe for Cmd<APP, MSG>

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.