pub struct Bridge {
    pub ip: IpAddr,
    pub username: String,
    /* private fields */
}
Expand description

The bridge is the central access point of the lamps is a Hue setup, and also the central access point of this library.

Fields

ip: IpAddr

The IP-address of the bridge.

username: String

This is the username of the currently logged in user.

Implementations

Create a bridge at this IP. If you know the IP-address, this is the fastest option. Note that this function does not validate whether a bridge is really present at the IP-address.

Example
let bridge = hueclient::Bridge::for_ip([192u8, 168, 0, 4]);

Scans the current network for Bridges, and if there is at least one, returns the first one that was found.

Example
let maybe_bridge = hueclient::Bridge::discover();

A convience wrapper around Bridge::disover, but panics if there is no bridge present.

Example
let brige = hueclient::Bridge::discover_required();
Panics

This function panics if there is no brige present.

Consumes the bidge and return a new one with a configured username.

Example
let bridge = hueclient::Bridge::for_ip([192u8, 168, 0, 4])
   .with_user("rVV05G0i52vQMMLn6BK3dpr0F3uDiqtDjPLPK2uj");

This function registers a new user at the provided brige, using devicetype as an identifier for that user. It returns an error if the button of the bridge was not pressed shortly before running this function.

Example
let bridge = hueclient::Bridge::for_ip([192u8, 168, 0, 4])
    .register_user("mylaptop")
    .unwrap();
// now this username d can be stored and reused
println!("the password was {}", bridge.username);

Returns a vector of all lights that are registered at this Bridge, sorted by their id’s. This function returns an error if bridge.username is None.

Example
let bridge = hueclient::Bridge::for_ip([192u8, 168, 0, 4])
   .with_user("rVV05G0i52vQMMLn6BK3dpr0F3uDiqtDjPLPK2uj");
for light in &bridge.get_all_lights().unwrap() {
    println!("{:?}", light);
}

Returns a vector of all groups that are registered at this Bridge, sorted by their id’s. This function returns an error if bridge.username is None.

Example
let bridge = hueclient::Bridge::for_ip([192u8, 168, 0, 4])
   .with_user("rVV05G0i52vQMMLn6BK3dpr0F3uDiqtDjPLPK2uj");
for group in &bridge.get_all_groups().unwrap() {
    println!("{:?}", group);
}

Returns a vector of all scenes that are registered at this Bridge, sorted by their id’s. This function returns an error if bridge.username is None.

Example
let bridge = hueclient::Bridge::for_ip([192u8, 168, 0, 4])
   .with_user("rVV05G0i52vQMMLn6BK3dpr0F3uDiqtDjPLPK2uj");
for scene in &bridge.get_all_scenes().unwrap() {
    println!("{:?}", scene);
}

Trait Implementations

Formats the value using the given formatter. 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

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.