Skip to main content

LevelControlHooks

Trait LevelControlHooks 

Source
pub trait LevelControlHooks {
    // Required method
    fn level(&self, level: Option<u8>);

    // Provided method
    fn frequency(&self, frequency: u16) -> bool { ... }
}
Expand description

What the device does when the level changes.

Required Methods§

Source

fn level(&self, level: Option<u8>)

The level changed.

None is §1.6.4.2’s null — “A value of null SHALL represent an undefined value” — which a device reports before it knows its own level, not as a synonym for zero.

Called for every step of a transition, because a transition is what the hardware is for: §1.6.7.1.1 asks that “the movement SHALL be as continuous as technically practical, i.e., not a step function”.

Provided Methods§

Source

fn frequency(&self, frequency: u16) -> bool

§1.6.7.5: change to frequency, or to the closest the device can generate.

Returns whether it could. “If the device cannot approximate the frequency, then it SHALL return a default response with an error code of CONSTRAINT_ERROR. Determining if a requested frequency can be approximated by a supported frequency is a manufacturer-specific decision” — which is why it is the product’s answer and not this cluster’s. The default refuses, which is right for a device with no Frequency feature.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§