Skip to main content

Output

Trait Output 

Source
pub trait Output: Device {
    // Required methods
    fn get_state(&self) -> State;
    fn set_state(&mut self, state: State) -> Result<State, Error>;
    fn get_default(&self) -> State;
    fn animate<S: Into<State>>(
        &mut self,
        state: S,
        duration: u64,
        transition: Easing,
    )
       where Self: Sized;
    fn is_busy(&self) -> bool;
    fn stop(&mut self);

    // Provided methods
    fn reset(&mut self) -> Result<State, Error> { ... }
    fn scale_state(
        &mut self,
        previous: State,
        target: State,
        progress: f32,
    ) -> State { ... }
}
Expand description

A trait for devices that can act on the world: the board “outputs” some state onto them.

This trait extends Device and is intended for actuators that requires the same capabilities as devices, including debugging, cloning, and concurrency support.

Required Methods§

Source

fn get_state(&self) -> State

Returns the actuator current state.

Source

fn set_state(&mut self, state: State) -> Result<State, Error>

Internal only: you should use the specific device state modifier functions instead.

Source

fn get_default(&self) -> State

Returns the actuator default (or neutral) state.

Source

fn animate<S: Into<State>>( &mut self, state: S, duration: u64, transition: Easing, )
where Self: Sized,

Animates the output of the device. In other word: the state of the device will be animated from current step to targeted step through an interpolation of in-between states. The function will last for the required duration and the interpolation will follow an easing transition function.

§Arguments
  • state: the targeted step to meet
  • duration: the duration (in ms) the animation is expected to last
  • transition: a transition Easing function to apply on the state.
Source

fn is_busy(&self) -> bool

Indicates the busy status, ie if the device is running an animation.

Source

fn stop(&mut self)

Stops the current animation, if any.

Provided Methods§

Source

fn reset(&mut self) -> Result<State, Error>

Resets the actuator to default (or neutral) state.

Source

fn scale_state( &mut self, previous: State, target: State, progress: f32, ) -> State

Internal only.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§