pub trait StringModel: Sized {
type Message: From<Event> + Send + 'static;
// Required methods
fn update(&mut self, msg: Self::Message) -> Cmd<Self::Message>;
fn view_string(&self) -> String;
// Provided method
fn init(&mut self) -> Cmd<Self::Message> { ... }
}Expand description
A simplified model trait that uses string-based views.
Instead of rendering directly to a Frame, implementations return
a String from view_string. The string is
converted to Text and rendered automatically.
This is ideal for quick prototyping and simple applications where full frame control isn’t needed.
Required Associated Types§
Required Methods§
Sourcefn update(&mut self, msg: Self::Message) -> Cmd<Self::Message>
fn update(&mut self, msg: Self::Message) -> Cmd<Self::Message>
Update the model in response to a message.
Sourcefn view_string(&self) -> String
fn view_string(&self) -> String
Render the view as a string.
The returned string is split by newlines and rendered into the frame. Each line is rendered left-aligned starting from the top of the frame area.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.