This commit is contained in:
LordMZTE 2021-10-21 17:01:39 +02:00
parent 868999bce8
commit f43322d841
2 changed files with 12 additions and 9 deletions

View file

@ -2,7 +2,10 @@ use std::{collections::HashMap, sync::Arc};
use crate::api::{
internal::{RegisterReq, RegisterResponse, RegisterSuccess},
ApiError, Group, Light, UpdateStatus,
ApiError,
Group,
Light,
UpdateStatus,
};
use miette::Diagnostic;
use reqwest::Client;
@ -50,7 +53,8 @@ impl<T> ActionStatus<T> {
}
impl Bridge {
/// tries to register a new user at the given bridge endpoint with a given username.
/// tries to register a new user at the given bridge endpoint with a given
/// username.
pub async fn register(
http: Arc<Client>,
devicetype: &str,

View file

@ -1,6 +1,5 @@
use std::sync::Arc;
use miette::Diagnostic;
use std::{io, time::Duration};
use std::{io, sync::Arc, time::Duration};
use thiserror::Error;
use tokio_stream::StreamExt;
use url::Url;
@ -24,8 +23,9 @@ pub enum DiscoverError {
}
/// Looks for hue bridges in the local network using the SSDP protocol.
/// A reqwest client is required, to fetch the device's description, which is needed to make sure a
/// device is a hue bridge. If a bridge is found, it's URL is returned.
/// A reqwest client is required, to fetch the device's description, which is
/// needed to make sure a device is a hue bridge. If a bridge is found, it's URL
/// is returned.
pub async fn discover_bridge(
reqwest_client: Arc<reqwest::Client>,
timeout: Duration,
@ -38,8 +38,8 @@ pub async fn discover_bridge(
if resp.location().ends_with("/description.xml") {
let mut url = Url::parse(resp.location())?;
// this check is needed so we don't think that all devices that use description.xml are
// hue bridges.
// this check is needed so we don't think that all devices that use
// description.xml are hue bridges.
if reqwest_client
.get(url.clone())
.send()
@ -64,4 +64,3 @@ pub enum Error {
#[error("JSON error")]
JsonError(#[from] serde_json::Error),
}