pub trait Model: Send + 'static {
type Msg: Send + 'static;
// Required methods
fn update(&mut self, msg: Self::Msg) -> Option<Cmd<Self::Msg>>;
fn view(&self) -> String;
// Provided methods
fn init(&mut self) -> Option<Cmd<Self::Msg>> { ... }
fn cursor(&self) -> Option<(u16, u16)> { ... }
}Expand description
A TEA model with string-based rendering.
Implement this trait for simple applications that render directly to a string.
For most use cases, prefer ElementModel which provides Flexbox layout.
Required Associated Types§
Required Methods§
Provided Methods§
Sourcefn init(&mut self) -> Option<Cmd<Self::Msg>>
fn init(&mut self) -> Option<Cmd<Self::Msg>>
Called once when the program starts. Return a command to perform initialization.
Sourcefn cursor(&self) -> Option<(u16, u16)>
fn cursor(&self) -> Option<(u16, u16)>
Where to place the real terminal cursor as (column, row), or None to
keep it hidden. Returning a position shows a normal blinking cursor at the
text insertion point — the correct behaviour for input fields (including
wide CJK glyphs), instead of a faked reverse-video block.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".