Skip to main content

Params

Trait Params 

Source
pub trait Params {
    // Required methods
    fn number(&self, key: &str) -> Option<f64>;
    fn word(&self, key: &str) -> Option<String>;
}
Expand description

Where an effect’s parameters come from.

A trait rather than a map, because the same parameters arrive from a Lua table in the compositor, from a slider in the preview, and from a literal in a test – and this crate may not depend on any of the three. Every parameter is optional and every effect has a default for each of its own, which is what makes { effect = "genie" } on its own a legal thing to write.

What this cannot do is complain. A parameter that is missing, misspelled or the wrong type is indistinguishable here from one nobody wrote, and there is no logger to say so – so both give the default. The check that catches it is script::shipped, which reads the names out of this crate and fails the build when the shipped Lua asks for one that does not exist.

Required Methods§

Source

fn number(&self, key: &str) -> Option<f64>

A number, if the caller has one under that name.

Source

fn word(&self, key: &str) -> Option<String>

A word: an enumerated choice, such as which way a genie is pulled.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl Params for ()

No parameters at all: every effect at its own defaults.

Source§

fn number(&self, _key: &str) -> Option<f64>

Source§

fn word(&self, _key: &str) -> Option<String>

Implementors§