matrix-sdk: Fix or silence a bunch of new clippy warnings

master
Damir Jelić 2021-03-30 13:05:13 +02:00
parent 84b187ec12
commit 02b44ca9ba
5 changed files with 23 additions and 19 deletions

View File

@ -92,7 +92,7 @@ pub enum Error {
/// An IO error happened. /// An IO error happened.
#[error(transparent)] #[error(transparent)]
IO(#[from] IoError), Io(#[from] IoError),
/// An error occurred in the Matrix client library. /// An error occurred in the Matrix client library.
#[error(transparent)] #[error(transparent)]

View File

@ -48,6 +48,7 @@ pub enum Error {
Random(#[from] RngError), Random(#[from] RngError),
} }
#[allow(clippy::from_over_into)]
impl Into<StoreError> for Error { impl Into<StoreError> for Error {
fn into(self) -> StoreError { fn into(self) -> StoreError {
match self { match self {

View File

@ -282,16 +282,16 @@ impl TryFrom<StateEvent<MemberEventContent>> for MemberEvent {
} }
} }
impl Into<SyncStateEvent<MemberEventContent>> for MemberEvent { impl From<MemberEvent> for SyncStateEvent<MemberEventContent> {
fn into(self) -> SyncStateEvent<MemberEventContent> { fn from(other: MemberEvent) -> SyncStateEvent<MemberEventContent> {
SyncStateEvent { SyncStateEvent {
content: self.content, content: other.content,
event_id: self.event_id, event_id: other.event_id,
sender: self.sender, sender: other.sender,
origin_server_ts: self.origin_server_ts, origin_server_ts: other.origin_server_ts,
state_key: self.state_key.to_string(), state_key: other.state_key.to_string(),
prev_content: self.prev_content, prev_content: other.prev_content,
unsigned: self.unsigned, unsigned: other.unsigned,
} }
} }
} }
@ -319,12 +319,12 @@ impl TryFrom<StrippedStateEvent<MemberEventContent>> for StrippedMemberEvent {
} }
} }
impl Into<StrippedStateEvent<MemberEventContent>> for StrippedMemberEvent { impl From<StrippedMemberEvent> for StrippedStateEvent<MemberEventContent> {
fn into(self) -> StrippedStateEvent<MemberEventContent> { fn from(other: StrippedMemberEvent) -> Self {
StrippedStateEvent { Self {
content: self.content, content: other.content,
sender: self.sender, sender: other.sender,
state_key: self.state_key.to_string(), state_key: other.state_key.to_string(),
} }
} }
} }

View File

@ -52,7 +52,7 @@ pub enum KeyExportError {
UnsupportedVersion, UnsupportedVersion,
/// The MAC of the encrypted payload is invalid. /// The MAC of the encrypted payload is invalid.
#[error("The MAC of the encrypted payload is invalid.")] #[error("The MAC of the encrypted payload is invalid.")]
InvalidMAC, InvalidMac,
/// The decrypted key export isn't valid UTF-8. /// The decrypted key export isn't valid UTF-8.
#[error(transparent)] #[error(transparent)]
InvalidUtf8(#[from] std::string::FromUtf8Error), InvalidUtf8(#[from] std::string::FromUtf8Error),
@ -64,7 +64,7 @@ pub enum KeyExportError {
Decode(#[from] DecodeError), Decode(#[from] DecodeError),
/// The key export doesn't all the required fields. /// The key export doesn't all the required fields.
#[error(transparent)] #[error(transparent)]
IO(#[from] std::io::Error), Io(#[from] std::io::Error),
} }
/// Try to decrypt a reader into a list of exported room keys. /// Try to decrypt a reader into a list of exported room keys.
@ -220,7 +220,7 @@ fn decrypt_helper(ciphertext: &str, passphrase: &str) -> Result<String, KeyExpor
let mut hmac = Hmac::<Sha256>::new_varkey(hmac_key).expect("Can't create an HMAC object"); let mut hmac = Hmac::<Sha256>::new_varkey(hmac_key).expect("Can't create an HMAC object");
hmac.update(&decoded[0..ciphertext_end]); hmac.update(&decoded[0..ciphertext_end]);
hmac.verify(&mac).map_err(|_| KeyExportError::InvalidMAC)?; hmac.verify(&mac).map_err(|_| KeyExportError::InvalidMac)?;
let mut ciphertext = &mut decoded[ciphertext_start..ciphertext_end]; let mut ciphertext = &mut decoded[ciphertext_start..ciphertext_end];
let mut aes = Aes256Ctr::new_var(&key, &iv).expect("Can't create an AES object"); let mut aes = Aes256Ctr::new_var(&key, &iv).expect("Can't create an AES object");

View File

@ -90,18 +90,21 @@ impl From<CrossSigningKey> for UserSigningPubkey {
} }
} }
#[allow(clippy::from_over_into)]
impl Into<CrossSigningKey> for MasterPubkey { impl Into<CrossSigningKey> for MasterPubkey {
fn into(self) -> CrossSigningKey { fn into(self) -> CrossSigningKey {
self.0.as_ref().clone() self.0.as_ref().clone()
} }
} }
#[allow(clippy::from_over_into)]
impl Into<CrossSigningKey> for UserSigningPubkey { impl Into<CrossSigningKey> for UserSigningPubkey {
fn into(self) -> CrossSigningKey { fn into(self) -> CrossSigningKey {
self.0.as_ref().clone() self.0.as_ref().clone()
} }
} }
#[allow(clippy::from_over_into)]
impl Into<CrossSigningKey> for SelfSigningPubkey { impl Into<CrossSigningKey> for SelfSigningPubkey {
fn into(self) -> CrossSigningKey { fn into(self) -> CrossSigningKey {
self.0.as_ref().clone() self.0.as_ref().clone()