pub trait Sandbox: Sized {
type Message: Debug + Send + Clone + 'static;
// Required methods
fn new() -> Self;
fn update(&mut self, messages: Vec<Self::Message>);
fn view(&mut self) -> Element<'_, Self::Message, PancursesRenderer>;
// Provided method
fn run() { ... }
}
Required Associated Types§
Required Methods§
Sourcefn update(&mut self, messages: Vec<Self::Message>)
fn update(&mut self, messages: Vec<Self::Message>)
Handles the dispatch of a message and updates the state of the sandbox
This function should define the update logic. All messages produced by user interaction will be handled here.
Sourcefn view(&mut self) -> Element<'_, Self::Message, PancursesRenderer>
fn view(&mut self) -> Element<'_, Self::Message, PancursesRenderer>
Request drawing the new state of the UI
Returns the root element to display using the renderer
Provided Methods§
Sourcefn run()
fn run()
Launches the sandbox and takes ownership of the current thread.
This should be the last thing you execute at the end of the entrypoint of your program.
Examples found in repository?
More examples
Additional examples can be found in:
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.