Struct lifxi::http::StateChange
source · pub struct StateChange {
pub power: Option<Power>,
pub duration: Option<Duration>,
pub infrared: Option<f32>,
pub hue: Option<i16>,
pub saturation: Option<f32>,
pub brightness: Option<f32>,
pub kelvin: Option<i16>,
}
Expand description
Encodes a desired state change.
This struct is intended for use with
Selected::change_state
, and it is encouraged to
use the builder methods instead of directly constructing a changeset.
Fields
power: Option<Power>
The desired power state.
duration: Option<Duration>
How long the transition should take.
infrared: Option<f32>
The desired change in infrared light level.
hue: Option<i16>
The desired change in hue.
saturation: Option<f32>
The desired change in saturation.
brightness: Option<f32>
The desired change in brightness.
kelvin: Option<i16>
The desired change in color temperature.
Implementations
sourceimpl StateChange
impl StateChange
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs an empty state change.
Identical to StateChange::new
.
sourcepub fn power<P: Into<Power>>(self, on: P) -> Self
pub fn power<P: Into<Power>>(self, on: P) -> Self
Builder function to change target power state.
Example
use lifxi::http::StateChange;
let new: StateChange = StateChange::builder().power(true);
sourcepub fn transition<T: Into<Duration>>(self, duration: T) -> Self
pub fn transition<T: Into<Duration>>(self, duration: T) -> Self
Builder function to change transition duration.
Example
use lifxi::http::StateChange;
let new: StateChange = StateChange::builder().transition(::std::time::Duration::from_secs(1));
sourcepub fn hue(self, hue: i16) -> Self
pub fn hue(self, hue: i16) -> Self
Builder function to set target change in hue.
Example
use lifxi::http::StateChange;
let new: StateChange = StateChange::builder().hue(-60);
sourcepub fn saturation(self, saturation: f32) -> Self
pub fn saturation(self, saturation: f32) -> Self
Builder function to set target change in saturation.
Example
use lifxi::http::StateChange;
let new: StateChange = StateChange::builder().saturation(-0.1);
sourcepub fn brightness(self, brightness: f32) -> Self
pub fn brightness(self, brightness: f32) -> Self
Builder function to set target change in brightness.
Example
use lifxi::http::StateChange;
let new: StateChange = StateChange::builder().brightness(0.4);
Trait Implementations
sourceimpl<'a, T: Select> AsRequest<StateChange> for ChangeState<'a, T>
impl<'a, T: Select> AsRequest<StateChange> for ChangeState<'a, T>
sourcefn body(&self) -> &StateChange
fn body(&self) -> &StateChange
The request body to be used, as configured by the user.
sourceimpl Clone for StateChange
impl Clone for StateChange
sourcefn clone(&self) -> StateChange
fn clone(&self) -> StateChange
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Default for StateChange
impl Default for StateChange
sourcefn default() -> StateChange
fn default() -> StateChange
Returns the “default value” for a type. Read more
sourceimpl<'de> Deserialize<'de> for StateChange
impl<'de> Deserialize<'de> for StateChange
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
sourceimpl Serialize for StateChange
impl Serialize for StateChange
Auto Trait Implementations
impl RefUnwindSafe for StateChange
impl Send for StateChange
impl Sync for StateChange
impl Unpin for StateChange
impl UnwindSafe for StateChange
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