Trait relm4::Model

source ·
pub trait Model: Sized {
    type Msg: 'static;
    type Widgets;
    type Components: Components<Self>;
}
Expand description

Trait that defines the types associated with the model.

A model can be anything that stores application state.

Example

struct AppModel {
    counter: u8,
}

enum AppMsg {
    Increment,
    Decrement,
}

impl Model for AppModel {
    type Msg = AppMsg;
    type Widgets = AppWidgets;
    type Components = ();
}

Required Associated Types§

source

type Msg: 'static

The message type that defines the messages that can be sent to modify the model.

source

type Widgets

The widgets type that can initialize and update the GUI with the data the model provides.

If you don’t want any widgets (for example for defining a worker), just use () here.

source

type Components: Components<Self>

The components type that initializes the child components of this model.

If you don’t want any component associated with this model just use ().

Implementations on Foreign Types§

source§

impl Model for ()

§

type Msg = ()

§

type Widgets = ()

§

type Components = ()

Implementors§