Struct lifxi::http::Selected

source ·
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

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();

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();

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();

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();

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();

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();
}

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();

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 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.