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
sourceimpl State
impl State
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs an empty state.
Identical to State::builder
.
sourcepub fn power<P: Into<Power>>(self, on: P) -> Self
pub fn power<P: Into<Power>>(self, on: P) -> Self
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));
sourcepub fn color(self, color: Color) -> Self
pub fn color(self, color: Color) -> Self
Builder function to set target color setting.
Example
use std::time::Duration;
use lifxi::http::{Color::*, State};
let new: State = State::builder().color(Red);
sourcepub fn brightness(self, brightness: f32) -> Self
pub fn brightness(self, brightness: f32) -> Self
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));
sourcepub fn transition<D: Into<Duration>>(self, duration: D) -> Self
pub fn transition<D: Into<Duration>>(self, duration: D) -> Self
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));
Trait Implementations
sourceimpl<'de> Deserialize<'de> for State
impl<'de> Deserialize<'de> for State
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnwindSafe for State
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more