Enum lifxi::http::Selector

source ·
pub enum Selector {
    All,
    Label(String),
    Id(String),
    GroupId(String),
    Group(String),
    LocationId(String),
    Location(String),
    SceneId(String),
}
Expand description

Selectors are used to identify one or more lights belonging to a particular account.

All resolutions of selectors are treated as sets, even if they are logically a single device, for consistency with the API (and to help prevent breakage).

Constraining Selectors

Selectors may be constrained to specific zones with the zoned method on Selector.

Randomization

A random device can be chosen from the list of devices matching a selector via the Randomize trait.

Variants

All

All devices on the user’s account.

Label(String)

Specifies a device with the given label.

Id(String)

Specifies a device with the given ID/serial number.

GroupId(String)

Specifies a collection of devices based on the given group ID.

Groups are discrete objects with their own IDs; use this to specify a group by ID instead of by label.

Group(String)

Specifies a collection of devices based on a group with the given label.

LocationId(String)

Specifies a collection of devices based on a location with the given ID.

Like groups, locations have their own IDs, so this option exists for locating devices by location ID instead of label.

Location(String)

Specifies a collection of devices based on a location with the given label.

SceneId(String)

Specifies a collection of devices from a scene with the given ID.

To get a list of scene IDs, use Scenes::list.

Implementations

Constrains the selector to only match the given zone(s).

Examples
use lifxi::http::{Selector, Zones};
// Devices in the "Living Room" group in zones 0 or 1 (ignores devices from other zones).
let sel = Selector::Group("Living Room".to_string()).zoned(0..2);
assert_eq!(&format!("{}", sel), "group:Living Room|0|1");
// Zones 254 or 255 only.
let sel = Selector::Group("Living Room".to_string()).zoned(254..);
assert_eq!(&format!("{}", sel), "group:Living Room|254|255");
// Zones 3 or 4 only.
let sel = Selector::Group("Living Room".to_string()).zoned(3..=4);
assert_eq!(&format!("{}", sel), "group:Living Room|3|4");
// Zone 1 only.
let sel = Selector::Group("Living Room".to_string()).zoned(1);
assert_eq!(&format!("{}", sel), "group:Living Room|1");
// Zones 1 or 255 only.
let sel = Selector::Group("Living Room".to_string()).zoned(vec![1, 255]);
assert_eq!(&format!("{}", sel), "group:Living Room|1|255");
// Zones 1 or 37 only.
let zones = vec![1, 37];
let iter = zones.iter(); // Or any I: Iterator<Item = u8> (or Iterator<Item = &u8>).
let sel = Selector::Group("Living Room".to_string()).zoned(iter.collect::<Zones>());
assert_eq!(&format!("{}", sel), "group:Living Room|1|37");

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Formats the value using the given formatter. Read more
The associated error which can be returned from parsing.
Parses a string s to return a value of this type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. 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
Compare self to key and return true if they are equal.

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
Converts the given value to a String. 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.