[][src]Struct huelib::bridge::Bridge

pub struct Bridge {
    pub username: String,
    pub ip_address: IpAddr,
    // some fields omitted
}

A bridge with IP address and username.

Fields

username: String

Name of the user that is connected to the bridge.

ip_address: IpAddr

IP address of the bridge.

Implementations

impl Bridge[src]

pub fn new(ip_address: IpAddr, username: impl Into<String>) -> Self[src]

Creates a new bridge.

Examples

Create a bridge with an already registered user.

use huelib::Bridge;
use std::net::{IpAddr, Ipv4Addr};

let bridge_ip = IpAddr::V4(Ipv4Addr::new(192, 168, 1, 2));
let bridge = Bridge::new(bridge_ip, "example-username");

pub fn set_config(&self, modifier: &Modifier) -> Result<Vec<Response<Modified>>>[src]

Modifies the configuration of the bridge

pub fn get_config(&self) -> Result<Config>[src]

Returns the configuration of the bridge.

pub fn set_light_attribute(
    &self,
    id: impl AsRef<str>,
    modifier: &AttributeModifier
) -> Result<Vec<Response<Modified>>>
[src]

Modifies attributes of a light.

pub fn set_light_state(
    &self,
    id: impl AsRef<str>,
    modifier: &StateModifier
) -> Result<Vec<Response<Modified>>>
[src]

Modifies the state of a light.

pub fn get_light(&self, id: impl AsRef<str>) -> Result<Light>[src]

Returns a light.

pub fn get_all_lights(&self) -> Result<Vec<Light>>[src]

Returns all lights that are connected to the bridge.

pub fn search_new_lights(&self, device_ids: Option<&[&str]>) -> Result<()>[src]

Starts searching for new lights.

The bridge will open the network for 40 seconds. The overall search might take longer since the configuration of new devices can take longer. If many devices are found the command will have to be issued a second time after discovery time has elapsed. If the command is received again during search the search will continue for at least an additional 40 seconds.

When the search has finished, new lights will be available using the get_new_lights function.

pub fn get_new_lights(&self) -> Result<Scan>[src]

Returns discovered lights.

pub fn delete_light(&self, id: impl AsRef<str>) -> Result<()>[src]

Deletes a light from the bridge.

pub fn create_group(&self, creator: &Creator) -> Result<String>[src]

Creates a new group.

pub fn set_group_attribute(
    &self,
    id: impl AsRef<str>,
    modifier: &AttributeModifier
) -> Result<Vec<Response<Modified>>>
[src]

Modifies attributes of a group.

pub fn set_group_state(
    &self,
    id: impl AsRef<str>,
    modifier: &StateModifier
) -> Result<Vec<Response<Modified>>>
[src]

Modifies the state of a group.

pub fn get_group(&self, id: impl AsRef<str>) -> Result<Group>[src]

Returns a group.

pub fn get_all_groups(&self) -> Result<Vec<Group>>[src]

Returns all groups.

pub fn delete_group(&self, id: impl AsRef<str>) -> Result<()>[src]

Deletes a group from the bridge.

pub fn create_scene(&self, creator: &Creator) -> Result<String>[src]

Creates a new scene.

pub fn set_scene(
    &self,
    id: impl AsRef<str>,
    modifier: &Modifier
) -> Result<Vec<Response<Modified>>>
[src]

Modifies the state and attributes of a scene.

pub fn get_scene(&self, id: impl AsRef<str>) -> Result<Scene>[src]

Returns a scene.

pub fn get_all_scenes(&self) -> Result<Vec<Scene>>[src]

Returns all scenes.

pub fn delete_scene(&self, id: impl AsRef<str>) -> Result<()>[src]

Deletes a scene.

pub fn get_capabilities(&self) -> Result<Capabilities>[src]

Returns the capabilities of resources.

pub fn create_schedule(&self, creator: &Creator) -> Result<String>[src]

Creates a new schedule and returns the identifier.

pub fn set_schedule(
    &self,
    id: impl AsRef<str>,
    modifier: &Modifier
) -> Result<Vec<Response<Modified>>>
[src]

Modifies attributes of a schedule.

pub fn get_schedule(&self, id: impl AsRef<str>) -> Result<Schedule>[src]

Returns a schedule.

pub fn get_all_schedules(&self) -> Result<Vec<Schedule>>[src]

Returns all schedules.

pub fn delete_schedule(&self, id: impl AsRef<str>) -> Result<()>[src]

Deletes a schedule.

Creates a new resourcelink and returns the identifier.

Modifies attributes of a resourcelink.

Returns a resourcelink.

Returns all resourcelinks.

Deletes a resourcelink.

pub fn set_sensor_attribute(
    &self,
    id: impl AsRef<str>,
    modifier: &AttributeModifier
) -> Result<Vec<Response<Modified>>>
[src]

Modifies attributes of a sensor.

pub fn set_sensor_state(
    &self,
    id: impl AsRef<str>,
    modifier: &StateModifier
) -> Result<Vec<Response<Modified>>>
[src]

Modifies the state of a sensor.

pub fn set_sensor_config(
    &self,
    id: impl AsRef<str>,
    modifier: &ConfigModifier
) -> Result<Vec<Response<Modified>>>
[src]

Modifies the configuration of a sensor.

pub fn get_sensor(&self, id: impl AsRef<str>) -> Result<Sensor>[src]

Returns a sensor.

pub fn get_all_sensors(&self) -> Result<Vec<Sensor>>[src]

Returns all sensors that are connected to the bridge.

pub fn search_new_sensors(&self, device_ids: Option<&[&str]>) -> Result<()>[src]

Starts searching for new sensors.

The bridge will open the network for 40 seconds. The overall search might take longer since the configuration of new devices can take longer. If many devices are found the command will have to be issued a second time after discovery time has elapsed. If the command is received again during search the search will continue for at least an additional 40 seconds.

When the search has finished, new sensors will be available using the get_new_sensors function.

pub fn get_new_sensors(&self) -> Result<Scan>[src]

Returns discovered sensors.

pub fn delete_sensor(&self, id: impl AsRef<str>) -> Result<()>[src]

Deletes a sensor from the bridge.

pub fn create_rule(&self, creator: &Creator) -> Result<String>[src]

Creates a new rule.

pub fn set_rule(
    &self,
    id: impl AsRef<str>,
    modifier: &Modifier
) -> Result<Vec<Response<Modified>>>
[src]

Modifies attributes of a rule.

pub fn get_rule(&self, id: impl AsRef<str>) -> Result<Rule>[src]

Returns a rule.

pub fn get_all_rules(&self) -> Result<Vec<Rule>>[src]

Returns all rules.

pub fn delete_rule(&self, id: impl AsRef<str>) -> Result<()>[src]

Deletes a rule.

Trait Implementations

impl Clone for Bridge[src]

impl Debug for Bridge[src]

impl Eq for Bridge[src]

impl PartialEq<Bridge> for Bridge[src]

impl StructuralEq for Bridge[src]

impl StructuralPartialEq for Bridge[src]

Auto Trait Implementations

impl RefUnwindSafe for Bridge

impl Send for Bridge

impl Sync for Bridge

impl Unpin for Bridge

impl UnwindSafe for Bridge

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Sealed<T> for T where
    T: ?Sized

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.