[][src]Struct huemanity::Bridge

pub struct Bridge {
    pub ip: String,
    pub key: String,
    pub client: Client,
    pub base_url: String,
    pub light_ids: Vec<u8>,
    pub n_lights: u8,
}

Fields

ip: String

The bridge struct represents a HUE bridge. The constructor for this struct link, tries to detect the light id's and is able to send new state to either a single light or all of the ones detected.

Currently to register a new bridge, you need to know 2 things:

  • the internal IP of the bridge (in future i'll implement ssdp)
  • the key assigned to you by the api/newdeveloper POST request see the documentation for the HUE API in order to see this. I will implement the authentication handshake request flow in the near future and in the CLI I will cache the key somewhere
key: Stringclient: Clientbase_url: Stringlight_ids: Vec<u8>n_lights: u8

Methods

impl Bridge[src]

Struct constructor that sets up the required interactions and also gets us the light id's as well as how many there are

pub fn send(
    &self,
    endpoint: &str,
    req_type: RequestType,
    params: Option<&Value>
) -> Result<Response, Box<dyn Error>>
[src]

Sends the a request with set parameters to the HUE API endpoint

pub fn state(&self, light: u8, state: &Value) -> Result<(), Box<dyn Error>>[src]

Given a light and a required state, send this state to the light.

pub fn state_all(&self, state: &Value) -> Result<(), Box<dyn Error>>[src]

Given a state send it to all lights found on bridge

pub fn collect_ids(&mut self) -> Result<(), Box<dyn Error>>[src]

Collect all found light ids

Trait Implementations

impl Debug 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, 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.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

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