Skip to main content

Params

Trait Params 

Source
pub trait Params:
    Serialize
    + DeserializeOwned
    + Clone
    + PartialEq
    + 'static {
    // Provided methods
    fn choices(_field: &str) -> Option<&'static [&'static str]> { ... }
    fn element_label(field: &str, _len: usize, i: usize) -> String { ... }
    fn on_choice(_value: &mut Value, _field: &str, _choice: &str) { ... }
}
Expand description

An op the editor can edit: it serializes to a JSON object whose numbers, short number lists, choices and switches are its parameters, and deserializing checks new values. The hooks say what JSON alone cannot (which text fields are choices, labels of list elements); each has a default, so impl Params for MyOp {} is enough for an op with numbers only.

Provided Methods§

Source

fn choices(_field: &str) -> Option<&'static [&'static str]>

The options of a text field shown as a menu (band: low pass, high pass…); None for a field that is not a choice (it is not shown).

Source

fn element_label(field: &str, _len: usize, i: usize) -> String

The label of element i of a list of len numbers (cutoff, 2, 0 → Low (Hz)).

Source

fn on_choice(_value: &mut Value, _field: &str, _choice: &str)

Adjusts the other values when a choice changes (a band change keeps the cutoffs it can).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§