diff --git a/src/apresolve.rs b/src/apresolve.rs index 80d1f4a5..9814a5b5 100644 --- a/src/apresolve.rs +++ b/src/apresolve.rs @@ -16,7 +16,7 @@ pub struct APResolveData { pub fn apresolve(handle: &Handle) -> Box> { let url = Url::parse(APRESOLVE_ENDPOINT).expect("invalid AP resolve URL"); - let client = Client::new(&handle); + let client = Client::new(handle); let response = client.get(url); let body = response.and_then(|response| { diff --git a/src/authentication/discovery.rs b/src/authentication/discovery.rs index 4e38a43f..e2c74df9 100644 --- a/src/authentication/discovery.rs +++ b/src/authentication/discovery.rs @@ -128,13 +128,13 @@ impl Discovery { let checksum_key = { let mut h = crypto::hmac::Hmac::new(crypto::sha1::Sha1::new(), &base_key); - h.input("checksum".as_bytes()); + h.input(b"checksum"); h.result().code().to_owned() }; let encryption_key = { let mut h = crypto::hmac::Hmac::new(crypto::sha1::Sha1::new(), &base_key); - h.input("encryption".as_bytes()); + h.input(b"encryption"); h.result().code().to_owned() }; @@ -149,9 +149,8 @@ impl Discovery { let decrypted = { let mut data = vec![0u8; encrypted.len()]; let mut cipher = crypto::aes::ctr(crypto::aes::KeySize::KeySize128, - &encryption_key[0..16], - &iv); - cipher.process(&encrypted, &mut data); + &encryption_key[0..16], iv); + cipher.process(encrypted, &mut data); String::from_utf8(data).unwrap() }; diff --git a/src/authentication/mod.rs b/src/authentication/mod.rs index c48227d3..17f99874 100644 --- a/src/authentication/mod.rs +++ b/src/authentication/mod.rs @@ -153,7 +153,7 @@ fn deserialize_protobuf_enum(de: D) -> Result where T: ProtobufEnum, D: serde::Deserializer { let v : i32 = try!(serde::Deserialize::deserialize(de)); - T::from_i32(v).ok_or(serde::de::Error::custom("Invalid enum value")) + T::from_i32(v).ok_or_else(|| serde::de::Error::custom("Invalid enum value")) } fn serialize_base64(v: &T, ser: S) -> Result @@ -197,7 +197,7 @@ pub fn get_credentials(device_name: &str, device_id: &str, (None, _, None) => { info!("No username provided and no stored credentials, starting discovery ..."); - discovery_login(device_name.clone(), device_id.clone()).unwrap() + discovery_login(device_name, device_id).unwrap() } } }