Skip to main content

Wiring

Trait Wiring 

Source
pub trait Wiring<M> {
    // Required method
    fn message(&mut self, name: &str, payload: Payload) -> Option<Handler<M>>;

    // Provided method
    fn asset(&mut self, path: &str) -> Option<Picture> { ... }
}
Expand description

What an application supplies a form that this crate cannot: its own message type, and its own pictures.

A plain closure implements this, which is all most forms need. Implement it on a type when the form also names pictures.

Required Methods§

Source

fn message(&mut self, name: &str, payload: Payload) -> Option<Handler<M>>

Turns a message name from the file into a message of the application’s own type. payload says which shape the widget needs.

Provided Methods§

Source

fn asset(&mut self, path: &str) -> Option<Picture>

Loads a picture, by a path relative to the form file.

The default has none, so a form naming a picture in an application that supplied no loader fails with the path in the message rather than drawing a hole. This crate decodes nothing and does not depend on denise-image: that keeps a board with its pictures compiled in from linking a decoder it will never call.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<M, F> Wiring<M> for F
where F: FnMut(&str, Payload) -> Option<Handler<M>>,