Trait Sandbox

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

Source

type Message: Debug + Send + Clone + 'static

Required Methods§

Source

fn new() -> Self

Initializes the Sanbox

Should return the initial state of the sandbox

Source

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.

Source

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§

Source

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?
examples/button.rs (line 55)
54fn main() {
55    MyState::run()
56}
More examples
Hide additional examples
examples/checkbox.rs (line 66)
65fn main() {
66    MyState::run()
67}
examples/hello.rs (line 42)
41fn main() {
42    MyState::run()
43}
examples/image.rs (line 32)
31fn main() {
32    MyState::run()
33}
examples/input.rs (line 56)
55fn main() {
56    MyState::run()
57}
examples/radio.rs (line 108)
107fn main() {
108    MyState::run()
109}

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.

Implementors§