From cbc859e624c89f288d50f563e8222e7affedace5 Mon Sep 17 00:00:00 2001 From: Ruben De Smet Date: Wed, 14 Apr 2021 18:33:01 +0200 Subject: [PATCH] Make clippy happy --- libsignal-service/src/configuration.rs | 6 +++--- libsignal-service/src/groups_v2/manager.rs | 5 ++--- libsignal-service/src/profile_cipher.rs | 2 +- libsignal-service/src/sealed_session_cipher.rs | 8 ++++---- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/libsignal-service/src/configuration.rs b/libsignal-service/src/configuration.rs index 59e351f87..3c97a4bda 100644 --- a/libsignal-service/src/configuration.rs +++ b/libsignal-service/src/configuration.rs @@ -107,10 +107,10 @@ impl ToString for SignalServers { } } -impl Into for SignalServers { - fn into(self) -> ServiceConfiguration { +impl From for ServiceConfiguration { + fn from(val: SignalServers) -> Self { // base configuration from https://github.com/signalapp/Signal-Desktop/blob/development/config/default.json - match self { + match val { // configuration with the Signal API staging endpoints // see: https://github.com/signalapp/Signal-Desktop/blob/master/config/default.json SignalServers::Staging => ServiceConfiguration { diff --git a/libsignal-service/src/groups_v2/manager.rs b/libsignal-service/src/groups_v2/manager.rs index c5f97be54..b1ddfef91 100644 --- a/libsignal-service/src/groups_v2/manager.rs +++ b/libsignal-service/src/groups_v2/manager.rs @@ -36,15 +36,14 @@ impl CredentialResponse { pub fn parse( self, ) -> Result, ServiceError> { - Ok(self - .credentials + self.credentials .into_iter() .map(|c| { let bytes = base64::decode(c.credential)?; let data = bincode::deserialize(&bytes)?; Ok((c.redemption_time, data)) }) - .collect::>()?) + .collect::>() } } diff --git a/libsignal-service/src/profile_cipher.rs b/libsignal-service/src/profile_cipher.rs index a6b9c1b70..c4eb5826a 100644 --- a/libsignal-service/src/profile_cipher.rs +++ b/libsignal-service/src/profile_cipher.rs @@ -73,7 +73,7 @@ fn pad_plaintext( let len = brackets .iter() .find(|x| **x >= bytes.len()) - .ok_or_else(|| ProfileCipherError::InputTooLong)?; + .ok_or(ProfileCipherError::InputTooLong)?; let len: usize = *len; bytes.resize(len, 0); diff --git a/libsignal-service/src/sealed_session_cipher.rs b/libsignal-service/src/sealed_session_cipher.rs index 10d49c3d4..628358d4c 100644 --- a/libsignal-service/src/sealed_session_cipher.rs +++ b/libsignal-service/src/sealed_session_cipher.rs @@ -199,8 +199,8 @@ impl UnidentifiedSenderMessage { fn into_bytes(self) -> Result, SealedSessionError> { use prost::Message; - let mut buf = vec![]; - buf.push(Self::CIPHERTEXT_VERSION << 4 | Self::CIPHERTEXT_VERSION); + let mut buf = + vec![Self::CIPHERTEXT_VERSION << 4 | Self::CIPHERTEXT_VERSION]; crate::proto::UnidentifiedSenderMessage { ephemeral_public: Some( self.ephemeral.to_bytes()?.as_slice().to_vec(), @@ -294,12 +294,12 @@ impl SealedSessionCipher { &content.into_bytes()?, )?; - Ok(UnidentifiedSenderMessage { + UnidentifiedSenderMessage { ephemeral: ephemeral.public(), encrypted_static: static_key_ciphertext, encrypted_message: message_bytes, } - .into_bytes()?) + .into_bytes() } pub fn decrypt(