Skip to main content

Params

Trait Params 

Source
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§

Source

fn param_count(&self) -> usize

Number of params; their indices are 0..param_count().

Source

fn param_name(&self, index: usize) -> Option<&'static str>

The name of the param at index, or None if it is out of range.

Source

fn param_at(&self, index: usize) -> Option<f32>

The value of the param at index, or None if it is out of range.

Source

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§

Source

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.

Source

fn param(&self, name: &str) -> Option<f32>

The value of the param called name, or None if there is no such param.

Source

fn set_param(&mut self, name: &str, value: f32) -> Result<(), ParamError>

Sets the param called name to value. On error the config is unchanged.

Source

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§

Source§

impl Params for QuadPlaneGuidance

The parts’ params, chained: hover (GUID_*), plane (PGUID_*), transition (TRAN_*), forward thrust (FWD_*), off-nose speed (OFFNOSE_*).

Source§

impl Params for QuadPlaneStabilizer

The parts’ params, chained: hover (STAB_*), plane (PSTAB_*).

Source§

impl Params for TailsitterGuidance

The parts’ params, chained: hover (GUID_*), plane (PGUID_*), transition (TRAN_*).

Source§

impl Params for TailsitterStabilizer

The parts’ params, chained: hover (STAB_*), plane (PSTAB_*).

Source§

impl<C, V, G, S, M, T> Params for FlightLoop<C, V, G, S, M, T>
where G: Params, S: Params,

Source§

impl<T> Params for T