Skip to main content

StringModel

Trait StringModel 

Source
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§

Source

type Message: From<Event> + Send + 'static

The message type for this model.

Required Methods§

Source

fn update(&mut self, msg: Self::Message) -> Cmd<Self::Message>

Update the model in response to a message.

Source

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§

Source

fn init(&mut self) -> Cmd<Self::Message>

Initialize the model with startup commands.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§