Struct lifxi::http::State

source ·
pub struct State {
    pub power: Option<Power>,
    pub color: Option<Color>,
    pub brightness: Option<f32>,
    pub duration: Option<Duration>,
    pub infrared: Option<f32>,
}
Expand description

Encodes a desired final state.

This struct should only be used directly when using Selected::set_states, and even then, it is encouraged to use the builder methods instead of directly constructing a set of changes.

Fields

power: Option<Power>

The desired power state, if appropriate.

color: Option<Color>

The desired color setting, if appropriate.

brightness: Option<f32>

The desired brightness level (0–1), if appropriate. Will take priority over any brightness specified in a color setting.

duration: Option<Duration>

How long the transition should take.

infrared: Option<f32>

If appropriate, the desired infrared light level (0–1).

Implementations

Constructs an empty state.

Identical to State::builder.

Creates a new builder.

Builder function to set target power setting.

Example
use std::time::Duration;
use lifxi::http::State;
let new: State = State::builder().power(true).transition(Duration::from_millis(800));

Builder function to set target color setting.

Example
use std::time::Duration;
use lifxi::http::{Color::*, State};
let new: State = State::builder().color(Red);

Builder function to set target brightness setting.

Example
use std::time::Duration;
use lifxi::http::State;
let new: State = State::builder().brightness(0.7).transition(Duration::from_millis(800));

Builder function to set animation duration.

Example
use std::time::Duration;
use lifxi::http::{Color::*, State};
let new: State = State::builder().color(Red).transition(Duration::from_millis(800));

Builder function to set target maximum infrared level.

Example
use lifxi::http::State;
let new: State = State::builder().infrared(0.8);

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.