Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
OtaK committed Aug 14, 2023
1 parent bb44d6f commit 17ecd59
Showing 1 changed file with 39 additions and 24 deletions.
63 changes: 39 additions & 24 deletions crypto-ffi/src/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ impl From<core_crypto::prelude::MlsGroupInfoEncryptionType> for MlsGroupInfoEncr
}
}

impl From<MlsGroupInfoEncryptionType> for core_crypto::prelude::MlsGroupInfoEncryptionType {
fn from(value: MlsGroupInfoEncryptionType) -> Self {
match value {
MlsGroupInfoEncryptionType::Plaintext => Self::Plaintext,
MlsGroupInfoEncryptionType::JweEncrypted => Self::JweEncrypted,
}
}
}

#[derive(Debug, Clone, Copy, uniffi::Enum)]
#[repr(u8)]
pub enum MlsRatchetTreeType {
Expand All @@ -231,6 +240,16 @@ impl From<core_crypto::prelude::MlsRatchetTreeType> for MlsRatchetTreeType {
}
}

impl From<MlsRatchetTreeType> for core_crypto::prelude::MlsRatchetTreeType {
fn from(value: MlsRatchetTreeType) -> Self {
match value {
MlsRatchetTreeType::Full => Self::Full,
MlsRatchetTreeType::Delta => Self::Delta,
MlsRatchetTreeType::ByRef => Self::ByRef,
}
}
}

#[derive(Debug, Clone, uniffi::Record)]
pub struct GroupInfoBundle {
pub encryption_type: MlsGroupInfoEncryptionType,
Expand Down Expand Up @@ -456,11 +475,11 @@ impl From<core_crypto::prelude::MlsWirePolicy> for MlsWirePolicy {
}
}

impl Into<core_crypto::prelude::MlsWirePolicy> for MlsWirePolicy {
fn into(self) -> core_crypto::prelude::MlsWirePolicy {
match self {
Self::Plaintext => core_crypto::prelude::MlsWirePolicy::Plaintext,
Self::Ciphertext => core_crypto::prelude::MlsWirePolicy::Ciphertext,
impl From<MlsWirePolicy> for core_crypto::prelude::MlsWirePolicy {
fn from(value: MlsWirePolicy) -> core_crypto::prelude::MlsWirePolicy {
match value {
MlsWirePolicy::Plaintext => core_crypto::prelude::MlsWirePolicy::Plaintext,
MlsWirePolicy::Ciphertext => core_crypto::prelude::MlsWirePolicy::Ciphertext,
}
}
}
Expand Down Expand Up @@ -501,11 +520,11 @@ impl From<core_crypto::prelude::MlsCredentialType> for MlsCredentialType {
}
}

impl Into<core_crypto::prelude::MlsCredentialType> for MlsCredentialType {
fn into(self) -> core_crypto::prelude::MlsCredentialType {
match self {
Self::Basic => core_crypto::prelude::MlsCredentialType::Basic,
Self::X509 => core_crypto::prelude::MlsCredentialType::X509,
impl From<MlsCredentialType> for core_crypto::prelude::MlsCredentialType {
fn from(value: MlsCredentialType) -> core_crypto::prelude::MlsCredentialType {
match value {
MlsCredentialType::Basic => core_crypto::prelude::MlsCredentialType::Basic,
MlsCredentialType::X509 => core_crypto::prelude::MlsCredentialType::X509,
}
}
}
Expand Down Expand Up @@ -803,13 +822,12 @@ impl CoreCrypto {
) -> CoreCryptoResult<MemberAddedMessages> {
let mut members = Invitee::group_to_conversation_member(clients, self.central.lock().await.provider())?;

Ok(self
.central
self.central
.lock()
.await
.add_members_to_conversation(&conversation_id, &mut members)
.await?
.try_into()?)
.try_into()
}

/// See [core_crypto::mls::MlsCentral::remove_members_from_conversation]
Expand All @@ -819,13 +837,12 @@ impl CoreCrypto {
clients: Vec<ClientId>,
) -> CoreCryptoResult<CommitBundle> {
let clients: Vec<core_crypto::prelude::ClientId> = clients.into_iter().map(|c| c.0).collect();
Ok(self
.central
self.central
.lock()
.await
.remove_members_from_conversation(&conversation_id, &clients)
.await?
.try_into()?)
.try_into()
}

/// See [core_crypto::mls::MlsCentral::mark_conversation_as_child_of]
Expand All @@ -840,26 +857,24 @@ impl CoreCrypto {

/// See [core_crypto::mls::MlsCentral::update_keying_material]
pub async fn update_keying_material(&self, conversation_id: Vec<u8>) -> CoreCryptoResult<CommitBundle> {
Ok(self
.central
self.central
.lock()
.await
.update_keying_material(&conversation_id)
.await?
.try_into()?)
.try_into()
}

/// See [core_crypto::mls::MlsCentral::commit_pending_proposals]
pub async fn commit_pending_proposals(&self, conversation_id: Vec<u8>) -> CoreCryptoResult<Option<CommitBundle>> {
Ok(self
.central
self.central
.lock()
.await
.commit_pending_proposals(&conversation_id)
.await
.transpose()
.map(|r| r?.try_into())
.transpose()?)
.transpose()
}

/// see [core_crypto::mls::MlsCentral::wipe_conversation]
Expand Down Expand Up @@ -1323,13 +1338,13 @@ impl CoreCrypto {
/// See [core_crypto::proteus::ProteusCentral::try_new]
pub async fn proteus_init(&self) -> CoreCryptoResult<()> {
proteus_impl! { self.proteus_last_error_code => {
let proteus = self.central
self.central
.lock()
.await
.proteus_init()
.await?;

CoreCryptoResult::Ok(proteus)
CoreCryptoResult::Ok(())
}}
}

Expand Down

0 comments on commit 17ecd59

Please sign in to comment.