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
sourceimpl Selector
impl Selector
sourcepub fn zoned<T>(self, z: T) -> Zonedwhere
T: Into<Zones>,
pub fn zoned<T>(self, z: T) -> Zonedwhere
T: Into<Zones>,
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
sourceimpl<'de> Deserialize<'de> for Selector
impl<'de> Deserialize<'de> for Selector
sourcefn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for Selector
impl Select for Selector
impl StructuralEq for Selector
impl StructuralPartialEq for Selector
Auto Trait Implementations
impl RefUnwindSafe for Selector
impl Send for Selector
impl Sync for Selector
impl Unpin for Selector
impl UnwindSafe for Selector
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
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.