Struct hust::bridge::Bridge[][src]

pub struct Bridge {
    pub url_base: String,
    pub device: BridgeDevice,
}

An object to communicate with a bridge.

The struct attributes contain the static properties of the bridge.

The methods can be used for communication like commands.

Fields

url_base: String

The base URL of the bridge, which all /api/ resources are below of.

device: BridgeDevice

The device properties of this bridge.

Implementations

impl Bridge[src]

pub fn from_description_url(url: String) -> Result<Bridge>[src]

Creates a Bridge object from a description URL like returned in SSDP discovery.

pub fn user_readable_identifier(&self) -> &str[src]

The unique but user-friendly name of the bridge.

pub fn register_user(&self) -> Result<String>[src]

Registers a user and return its name.

Save it to communicate further with the bridge, e.g. to switch lights.

Note that the button of the bridge has to be pressed.

pub fn modify_light<T: Serialize>(
    &self,
    user: &str,
    light: &str,
    key: &str,
    value: T
) -> Result<()>
[src]

Set an attribute of a light.

user is the user you had to register with register_user.

light is the identifier of the light. All identifiers can be obtained by listing the HashMap keys of get_all_lights.

key can be any attribute of crate::lights::LightState.

pub fn get_all_lights(&self, user: &str) -> Result<HashMap<String, Light>>[src]

List all lights connected to this bridge

The listed lights are bundled with their state. You have to specify a user in order to be authenticated.

pub fn switch_light(&self, user: &str, light: &str, on: bool) -> Result<()>[src]

Switch light on / off.

user is the user you had to register with register_user.

light is the identifier of the light. All identifiers can be obtained by listing the HashMap keys of get_all_lights.

To switch the light off, specify on as false.

Trait Implementations

impl Debug for Bridge[src]

impl<'de> Deserialize<'de> for Bridge[src]

impl Serialize 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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

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

impl<T> Instrument for T[src]

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

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.