Skip to main content

Control

Trait Control 

Source
pub trait Control: Send + Sync {
    // Required method
    fn render<'a>(&self, cx: &'a Cx, input: ControlInput) -> BoxView<'a>;

    // Provided method
    fn display<'a>(&self, cx: &'a Cx, value: &str) -> BoxView<'a> { ... }
}
Expand description

Renders a field’s input from a ControlInput and its stored value for display, using a hidden field for a state that submits nothing.

struct Color;

impl Control for Color {
    fn render<'a>(&self, cx: &'a Cx, input: ControlInput) -> BoxView<'a> {
        let attrs = input.attributes(cx);
        view! { cx => <input type="color" (attrs)> }.boxed()
    }
}

Field::custom(Theme::fields().accent(), Color);

Required Methods§

Source

fn render<'a>(&self, cx: &'a Cx, input: ControlInput) -> BoxView<'a>

Provided Methods§

Source

fn display<'a>(&self, cx: &'a Cx, value: &str) -> BoxView<'a>

Shows the stored value, as text by default.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§