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.
#[error(transparent)]
IO(#[from] IoError),
Io(#[from] IoError),
/// An error occurred in the Matrix client library.
#[error(transparent)]

View File

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

View File

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

View File

@ -52,7 +52,7 @@ pub enum KeyExportError {
UnsupportedVersion,
/// 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.
#[error(transparent)]
InvalidUtf8(#[from] std::string::FromUtf8Error),
@ -64,7 +64,7 @@ pub enum KeyExportError {
Decode(#[from] DecodeError),
/// The key export doesn't all the required fields.
#[error(transparent)]
IO(#[from] std::io::Error),
Io(#[from] std::io::Error),
}
/// 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");
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 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 {
fn into(self) -> CrossSigningKey {
self.0.as_ref().clone()
}
}
#[allow(clippy::from_over_into)]
impl Into<CrossSigningKey> for UserSigningPubkey {
fn into(self) -> CrossSigningKey {
self.0.as_ref().clone()
}
}
#[allow(clippy::from_over_into)]
impl Into<CrossSigningKey> for SelfSigningPubkey {
fn into(self) -> CrossSigningKey {
self.0.as_ref().clone()