pub struct Selected<'a, T: Select> { /* private fields */ }
Expand description
A scoped request that can be used to get or set light states.
Created by Client::select
.
Implementations
sourceimpl<'a, T> Selected<'a, T>where
T: Select,
impl<'a, T> Selected<'a, T>where
T: Select,
sourcepub fn list(&'a self) -> Request<'a, ()>
pub fn list(&'a self) -> Request<'a, ()>
Creates a request to get information about the selected lights (including their states).
Example
use lifxi::http::prelude::*;
let client = Client::new("foo");
let lights = client
.select(Selector::All)
.list()
.send();
sourcepub fn set_state(&'a self) -> SetState<'a, T>
pub fn set_state(&'a self) -> SetState<'a, T>
Creates a request to set a uniform state on one or more lights.
Example
use lifxi::http::prelude::*;
let client = Client::new("foo");
let lights = client
.select(Selector::All)
.set_state()
.color(Color::Red)
.power(true)
.brightness(0.1)
.transition(::std::time::Duration::new(7, 0))
.infrared(0.8)
.send();
sourcepub fn change_state(&'a self) -> ChangeState<'a, T>
pub fn change_state(&'a self) -> ChangeState<'a, T>
Creates a request to incrementally change state on one or more lights.
Example
use lifxi::http::prelude::*;
let client = Client::new("foo");
let lights = client
.select(Selector::All)
.change_state()
.power(true)
.brightness(0.4)
.saturation(-0.1)
.brightness(0.1)
.kelvin(-100)
.transition(::std::time::Duration::new(7, 0))
.infrared(0.1)
.send();
sourcepub fn breathe(&'a self, color: Color) -> Breathe<'a, T>
pub fn breathe(&'a self, color: Color) -> Breathe<'a, T>
Creates a request to begin a “breathe” effect.
Example
use lifxi::http::prelude::*;
let client = Client::new("foo");
let lights = client
.select(Selector::All)
.breathe(Color::Orange)
.from(Color::Purple)
.power(true)
.cycles(100)
.period(::std::time::Duration::new(20, 0))
.peak(0.8)
.persist(true)
.send();
sourcepub fn pulse(&'a self, color: Color) -> Pulse<'a, T>
pub fn pulse(&'a self, color: Color) -> Pulse<'a, T>
Creates a request to begin a “pulse” effect.
Example
use lifxi::http::prelude::*;
let client = Client::new("foo");
let lights = client
.select(Selector::All)
.pulse(Color::Orange)
.from(Color::Purple)
.power(true)
.cycles(100)
.period(::std::time::Duration::new(20, 0))
.persist(true)
.send();
sourcepub fn cycle(&'a self) -> Cycle<'a, T>
pub fn cycle(&'a self) -> Cycle<'a, T>
Begins the process of specifying a cycle.
Cycles provide a convenient method of moving through a set of changes without client-side logic; the API keeps track of the state of the bulb and will move to the next appropriate state upon repeated requests.
Example
use lifxi::http::prelude::*;
fn client() -> Client {
// TODO: Add lazy-static dependency and use it to make a shared client.
unimplemented!()
}
// Let's make a light show we can advance by pressing a button!
// Each press of our internet-connected button calls this function.
fn next() {
let red = State::builder().color(Color::Red);
let green = State::builder().color(Color::Green);
let white = State::builder().color(Color::White);
let shared = State::builder().color(Color::Brightness(1.0)).power(true);
let result = client()
.select(Selector::All)
.cycle()
.add(red)
.add(green)
.add(white)
.rev() // Let's mix it up a little!
.default(shared)
.send();
}
sourcepub fn toggle(&'a self) -> Toggle<'a, T>
pub fn toggle(&'a self) -> Toggle<'a, T>
Creates a request to toggle power to the selected light(s), with an optional transition
time (see Toggle::transition
for details).
Notes
All selected lights will have the same power state after this request is processed; if all are off, all will be turned on, but if any are on, all will be turned off.
Example
use lifxi::http::prelude::*;
let client = Client::new("foo");
let result = client
.select(Selector::All)
.toggle()
.transition(::std::time::Duration::new(2, 0))
.send();