pub trait Params {
// Required methods
fn param_count(&self) -> usize;
fn param_name(&self, index: usize) -> Option<&'static str>;
fn param_at(&self, index: usize) -> Option<f32>;
fn set_param_at(
&mut self,
index: usize,
value: f32,
) -> Result<(), ParamError>;
// Provided methods
fn param_index(&self, name: &str) -> Option<usize> { ... }
fn param(&self, name: &str) -> Option<f32> { ... }
fn set_param(&mut self, name: &str, value: f32) -> Result<(), ParamError> { ... }
fn visit_params(&self, f: &mut dyn FnMut(&'static str, f32)) { ... }
}Expand description
Read, write, and list a component’s tunable values by index or by name.
Implementors provide the four index methods; name lookup, param,
set_param, and visit_params are built on
them.
Contract: a successful write stores the value as given, up to the rounding of a unit
conversion (degrees ↔ radians); an out-of-range value is rejected, never clamped or
adjusted. Implementors must uphold it (for the blanket impl: each Param reads back what
it wrote, and set_config commits the config unchanged or rejects it), because a link
confirms a write by echoing the value it was sent.
Required Methods§
Sourcefn param_count(&self) -> usize
fn param_count(&self) -> usize
Number of params; their indices are 0..param_count().
Sourcefn param_name(&self, index: usize) -> Option<&'static str>
fn param_name(&self, index: usize) -> Option<&'static str>
The name of the param at index, or None if it is out of range.
Sourcefn param_at(&self, index: usize) -> Option<f32>
fn param_at(&self, index: usize) -> Option<f32>
The value of the param at index, or None if it is out of range.
Sourcefn set_param_at(&mut self, index: usize, value: f32) -> Result<(), ParamError>
fn set_param_at(&mut self, index: usize, value: f32) -> Result<(), ParamError>
Sets the param at index to value. Out of range is ParamError::Unknown. On error
the config is unchanged.
Provided Methods§
Sourcefn param_index(&self, name: &str) -> Option<usize>
fn param_index(&self, name: &str) -> Option<usize>
The index of the param called name, or None if there is no such param. On a
duplicate name, the first index.
Sourcefn param(&self, name: &str) -> Option<f32>
fn param(&self, name: &str) -> Option<f32>
The value of the param called name, or None if there is no such param.
Sourcefn set_param(&mut self, name: &str, value: f32) -> Result<(), ParamError>
fn set_param(&mut self, name: &str, value: f32) -> Result<(), ParamError>
Sets the param called name to value. On error the config is unchanged.
Sourcefn visit_params(&self, f: &mut dyn FnMut(&'static str, f32))
fn visit_params(&self, f: &mut dyn FnMut(&'static str, f32))
Calls f with every param’s name and value, in index order.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl Params for QuadPlaneGuidance
The parts’ params, chained: hover (GUID_*), plane (PGUID_*), transition (TRAN_*),
forward thrust (FWD_*), off-nose speed (OFFNOSE_*).
impl Params for QuadPlaneStabilizer
The parts’ params, chained: hover (STAB_*), plane (PSTAB_*).
impl Params for TailsitterGuidance
The parts’ params, chained: hover (GUID_*), plane (PGUID_*), transition (TRAN_*).
impl Params for TailsitterStabilizer
The parts’ params, chained: hover (STAB_*), plane (PSTAB_*).