Skip to content

Commit 28a74b7

Browse files
committed
style: run formatter on comments and doc strings
1 parent a485eb5 commit 28a74b7

File tree

167 files changed

+1886
-1252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+1886
-1252
lines changed

crypto-ffi/src/bundles/commit.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ pub struct CommitBundle {
1414
pub commit: Vec<u8>,
1515
/// `GroupInfo` if the commit is merged
1616
pub group_info: GroupInfoBundle,
17-
/// An encrypted message to fan out to all other conversation members in the new epoch
17+
/// An encrypted message to fan out to all other conversation members in the
18+
/// new epoch
1819
pub encrypted_message: Option<Vec<u8>>,
1920
}
2021

crypto-ffi/src/ciphersuite.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
//! Ciphersuites in bindings
22
//!
3-
//! Both wasm-bindgen and uniffi support emitting enums, as long as they directly implement the enum;
4-
//! it doesn't work on newtypes around external enums. We therefore redefine the ciphersuites enum
5-
//! here with appropriate annotations such that it gets exported to all relevant bindings.
3+
//! Both wasm-bindgen and uniffi support emitting enums, as long as they
4+
//! directly implement the enum; it doesn't work on newtypes around external
5+
//! enums. We therefore redefine the ciphersuites enum here with appropriate
6+
//! annotations such that it gets exported to all relevant bindings.
67
78
use core_crypto::{Ciphersuite as CryptoCiphersuite, MlsCiphersuite};
89

crypto-ffi/src/client_id.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/// A Client identifier
22
///
3-
/// A unique identifier for clients. A client is an identifier for each App a user is using, such as desktop,
4-
/// mobile, etc. Users can have multiple clients.
5-
/// More information [here](https://messaginglayersecurity.rocks/mls-architecture/draft-ietf-mls-architecture.html#name-group-members-and-clients)
3+
/// A unique identifier for clients. A client is an identifier for each App a
4+
/// user is using, such as desktop, mobile, etc. Users can have multiple
5+
/// clients. More information [here](https://messaginglayersecurity.rocks/mls-architecture/draft-ietf-mls-architecture.html#name-group-members-and-clients)
66
#[derive(Debug, Clone, Eq, Hash, PartialEq, derive_more::From, uniffi::Object)]
77
pub struct ClientId(pub(crate) core_crypto::ClientId);
88

crypto-ffi/src/core_crypto/client.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ use crate::{Ciphersuite, CoreCryptoFfi, CoreCryptoResult, CredentialType};
22

33
#[uniffi::export]
44
impl CoreCryptoFfi {
5-
/// Gets the public key from a [`Credential`][crate::Credential] which has been added to this client.
5+
/// Gets the public key from a [`Credential`][crate::Credential] which has
6+
/// been added to this client.
67
///
78
/// The ciphersuite and credential type act as filters.
89
///
9-
/// If there exist multiple credentials which match these filters, this returns the one with
10-
/// the latest `earliest_validity`.
10+
/// If there exist multiple credentials which match these filters, this
11+
/// returns the one with the latest `earliest_validity`.
1112
///
1213
/// See [core_crypto::transaction_context::TransactionContext::client_public_key]
1314
pub async fn client_public_key(

crypto-ffi/src/core_crypto/command/mod.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use std::sync::Arc;
55

66
use crate::{CoreCryptoContext, CoreCryptoFfi, CoreCryptoResult};
77

8-
/// A `CoreCryptoCommand` has an `execute` method which accepts a `CoreCryptoContext` and returns nothing.
8+
/// A `CoreCryptoCommand` has an `execute` method which accepts a
9+
/// `CoreCryptoContext` and returns nothing.
910
///
1011
/// It is the argument to a `CoreCrypto::transaction` call.
1112
#[uniffi::export(with_foreign)]
@@ -16,7 +17,8 @@ pub trait CoreCryptoCommand: Send + Sync {
1617
async fn execute(&self, context: Arc<CoreCryptoContext>) -> CoreCryptoResult<()>;
1718
}
1819

19-
/// When building outside WASM, any async function of appropriate signature is a `CoreCryptoCommand`.
20+
/// When building outside WASM, any async function of appropriate signature is a
21+
/// `CoreCryptoCommand`.
2022
2123
#[cfg_attr(target_family = "wasm", async_trait::async_trait(?Send))]
2224
#[cfg_attr(not(target_family = "wasm"), async_trait::async_trait)]
@@ -35,11 +37,13 @@ type Command = Arc<dyn CoreCryptoCommand>;
3537

3638
#[uniffi::export]
3739
impl CoreCryptoFfi {
38-
/// Starts a new transaction in Core Crypto. If the callback succeeds, it will be committed,
39-
/// otherwise, every operation performed with the context will be discarded.
40+
/// Starts a new transaction in Core Crypto. If the callback succeeds, it
41+
/// will be committed, otherwise, every operation performed with the
42+
/// context will be discarded.
4043
///
41-
/// When calling this function from within Rust, async functions accepting a context
42-
/// implement `CoreCryptoCommand`, so operations can be defined inline as follows:
44+
/// When calling this function from within Rust, async functions accepting a
45+
/// context implement `CoreCryptoCommand`, so operations can be defined
46+
/// inline as follows:
4347
///
4448
/// ```ignore
4549
/// core_crypto.transaction(Arc::new(async |context| {
@@ -54,9 +58,9 @@ impl CoreCryptoFfi {
5458
inner: inner_context.clone(),
5559
};
5660

57-
// We need one more layer of Arc-wrapping in uniffi. It's kind of silly, given the
58-
// also-mandatory Arc-wrapping internally, but that's the price we have to pay in order
59-
// to reuse the code in both target contexts.
61+
// We need one more layer of Arc-wrapping in uniffi. It's kind of silly, given
62+
// the also-mandatory Arc-wrapping internally, but that's the price we
63+
// have to pay in order to reuse the code in both target contexts.
6064
let context = Arc::new(context);
6165

6266
let result = command.execute(context).await;

crypto-ffi/src/core_crypto/command/transaction_helper.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ use crate::{CoreCryptoContext, CoreCryptoResult};
77

88
/// Helper for working with the new transasction interface.
99
///
10-
/// This helper serves two purposes: to present a `FnOnce` interface for transactions,
11-
/// and to allow the extraction of data from within transactions.
10+
/// This helper serves two purposes: to present a `FnOnce` interface for
11+
/// transactions, and to allow the extraction of data from within transactions.
1212
///
1313
/// ## Extracting Data
1414
///
15-
/// The `CoreCryptoCommand` interface requires some kind of interior mutability to extract
16-
/// any data: it takes an immutable reference to the implementing item, and returns the unit struct
17-
/// in the success case.
15+
/// The `CoreCryptoCommand` interface requires some kind of interior mutability
16+
/// to extract any data: it takes an immutable reference to the implementing
17+
/// item, and returns the unit struct in the success case.
1818
///
19-
/// That pattern is relatively arcane and verbose, particularly when we just want to smuggle out
20-
/// some data from within the transaction. This helper is intended to ease and automate
21-
/// that process.
19+
/// That pattern is relatively arcane and verbose, particularly when we just
20+
/// want to smuggle out some data from within the transaction. This helper is
21+
/// intended to ease and automate that process.
2222
///
2323
/// Use it like this (pseudocode):
2424
///

crypto-ffi/src/core_crypto/epoch_observer.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,29 @@ pub trait EpochObserver: Send + Sync {
2525
///
2626
/// <div class="warning">
2727
/// This function must not block! Foreign implementors of this interface can
28-
/// spawn a task indirecting the notification, or (unblocking) send the notification
29-
/// on some kind of channel, or anything else, as long as the operation completes
30-
/// quickly.
28+
/// spawn a task indirecting the notification, or (unblocking) send the
29+
/// notification on some kind of channel, or anything else, as long as
30+
/// the operation completes quickly.
3131
/// </div>
3232
///
33-
/// Though the signature includes an error type, that error is only present because
34-
/// it is required by `uniffi` in order to handle panics. This function should suppress
35-
/// and ignore internal errors instead of propagating them, to the maximum extent possible.
33+
/// Though the signature includes an error type, that error is only present
34+
/// because it is required by `uniffi` in order to handle panics. This
35+
/// function should suppress and ignore internal errors instead of
36+
/// propagating them, to the maximum extent possible.
3637
async fn epoch_changed(
3738
&self,
3839
conversation_id: ConversationIdMaybeArc,
3940
epoch: u64,
4041
) -> Result<(), EpochChangedReportingError>;
4142
}
4243

43-
/// This shim bridges the public `EpochObserver` interface with the internal one defined by `core-crypto`.
44+
/// This shim bridges the public `EpochObserver` interface with the internal one
45+
/// defined by `core-crypto`.
4446
///
45-
/// This is slightly unfortunate, as it introduces an extra layer of indirection before a change notice can
46-
/// actually reach its foreign target. However, the orphan rule prevents us from just tying the two traits
47-
/// together directly, so this is the straightforward way to accomplish that.
47+
/// This is slightly unfortunate, as it introduces an extra layer of indirection
48+
/// before a change notice can actually reach its foreign target. However, the
49+
/// orphan rule prevents us from just tying the two traits together directly, so
50+
/// this is the straightforward way to accomplish that.
4851
struct ObserverShim(Arc<dyn EpochObserver>);
4952

5053
#[cfg_attr(target_family = "wasm", async_trait::async_trait(?Send))]
@@ -57,7 +60,8 @@ impl core_crypto::mls::EpochObserver for ObserverShim {
5760
.await
5861
{
5962
// we don't _care_ if an error is thrown by the notification function, per se,
60-
// but this would probably be useful information for downstream debugging efforts
63+
// but this would probably be useful information for downstream debugging
64+
// efforts
6165
log::warn!(
6266
conversation_id = &conversation_id,
6367
epoch,
@@ -72,8 +76,9 @@ impl core_crypto::mls::EpochObserver for ObserverShim {
7276
impl CoreCryptoFfi {
7377
/// Add an epoch observer to this client.
7478
///
75-
/// This function should be called 0 or 1 times in a session's lifetime. If called
76-
/// when an epoch observer already exists, this will return an error.
79+
/// This function should be called 0 or 1 times in a session's lifetime. If
80+
/// called when an epoch observer already exists, this will return an
81+
/// error.
7782
pub async fn register_epoch_observer(&self, epoch_observer: Arc<dyn EpochObserver>) -> CoreCryptoResult<()> {
7883
let shim = Arc::new(ObserverShim(epoch_observer));
7984
self.inner

crypto-ffi/src/core_crypto/history_observer.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,34 @@ pub enum NewHistoryClientReportingError {
2222
pub trait HistoryObserver: Send + Sync {
2323
/// This function will be called every time a new history client is created.
2424
///
25-
/// The `secret` parameter is the secret associated with the new history client
25+
/// The `secret` parameter is the secret associated with the new history
26+
/// client
2627
///
2728
/// <div class="warning">
2829
/// This function must not block! Foreign implementors of this interface can
29-
/// spawn a task indirecting the notification, or (unblocking) send the notification
30-
/// on some kind of channel, or anything else, as long as the operation completes
31-
/// quickly.
30+
/// spawn a task indirecting the notification, or (unblocking) send the
31+
/// notification on some kind of channel, or anything else, as long as
32+
/// the operation completes quickly.
3233
/// </div>
3334
///
34-
/// Though the signature includes an error type, that error is only present because
35-
/// it is required by `uniffi` in order to handle panics. This function should suppress
36-
/// and ignore internal errors instead of propagating them, to the maximum extent possible.
35+
/// Though the signature includes an error type, that error is only present
36+
/// because it is required by `uniffi` in order to handle panics. This
37+
/// function should suppress and ignore internal errors instead of
38+
/// propagating them, to the maximum extent possible.
3739
async fn history_client_created(
3840
&self,
3941
conversation_id: ConversationIdMaybeArc,
4042
secret: HistorySecret,
4143
) -> Result<(), NewHistoryClientReportingError>;
4244
}
4345

44-
/// This shim bridges the public `HistoryObserver` interface with the internal one defined by `core-crypto`.
46+
/// This shim bridges the public `HistoryObserver` interface with the internal
47+
/// one defined by `core-crypto`.
4548
///
46-
/// This is slightly unfortunate, as it introduces an extra layer of indirection before a change notice can
47-
/// actually reach its foreign target. However, the orphan rule prevents us from just tying the two traits
48-
/// together directly, so this is the straightforward way to accomplish that.
49+
/// This is slightly unfortunate, as it introduces an extra layer of indirection
50+
/// before a change notice can actually reach its foreign target. However, the
51+
/// orphan rule prevents us from just tying the two traits together directly, so
52+
/// this is the straightforward way to accomplish that.
4953
struct ObserverShim(Arc<dyn HistoryObserver>);
5054

5155
#[cfg_attr(target_family = "wasm", async_trait(?Send))]
@@ -65,7 +69,8 @@ impl core_crypto::mls::HistoryObserver for ObserverShim {
6569
.await
6670
{
6771
// we don't _care_ if an error is thrown by the notification function, per se,
68-
// but this would probably be useful information for downstream debugging efforts
72+
// but this would probably be useful information for downstream debugging
73+
// efforts
6974
log::warn!(
7075
conversation_id = conversation_id,
7176
err = log::kv::Value::from_dyn_error(&err);
@@ -79,8 +84,9 @@ impl core_crypto::mls::HistoryObserver for ObserverShim {
7984
impl CoreCryptoFfi {
8085
/// Add a history observer to this client.
8186
///
82-
/// This function should be called 0 or 1 times in a session's lifetime. If called
83-
/// when an history observer already exists, this will return an error.
87+
/// This function should be called 0 or 1 times in a session's lifetime. If
88+
/// called when an history observer already exists, this will return an
89+
/// error.
8490
pub async fn register_history_observer(&self, history_observer: Arc<dyn HistoryObserver>) -> CoreCryptoResult<()> {
8591
let shim = Arc::new(ObserverShim(history_observer));
8692
self.inner

crypto-ffi/src/core_crypto/logger.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ pub enum LoggingError {
5757
Ffi(#[from] uniffi::UnexpectedUniFFICallbackError),
5858
}
5959

60-
/// This trait is used to provide a callback mechanism to hook up the respective platform logging system.
60+
/// This trait is used to provide a callback mechanism to hook up the respective
61+
/// platform logging system.
6162
#[uniffi::export(with_foreign)]
6263
pub trait CoreCryptoLogger: std::fmt::Debug + Send + Sync {
6364
/// Core Crypto will call this method whenever it needs to log a message.
6465
///
65-
/// This function catches panics and other unexpected errors. In those cases, it writes to `stderr`.
66+
/// This function catches panics and other unexpected errors. In those
67+
/// cases, it writes to `stderr`.
6668
fn log(&self, level: CoreCryptoLogLevel, message: String, context: Option<String>) -> Result<(), LoggingError>;
6769
}
6870

@@ -77,7 +79,8 @@ impl CoreCryptoLogger for DummyLogger {
7779
}
7880
}
7981

80-
/// The uniffi log shim is a simple wrapper around the foreign implementer of the trait
82+
/// The uniffi log shim is a simple wrapper around the foreign implementer of
83+
/// the trait
8184
#[derive(Clone, derive_more::Constructor)]
8285
struct LogShim {
8386
logger: Arc<dyn CoreCryptoLogger>,

crypto-ffi/src/core_crypto/mls_transport.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
//! Implement the MLS Transport interface.
22
//!
3-
//! Unfortunately, there is no good way to reuse code between uniffi and wasm for an interface
4-
//! like this; the fundamental techniques in use are very different. So we just have to feature-gate
5-
//! everything.
3+
//! Unfortunately, there is no good way to reuse code between uniffi and wasm
4+
//! for an interface like this; the fundamental techniques in use are very
5+
//! different. So we just have to feature-gate everything.
66
use std::{fmt, sync::Arc};
77

88
use core_crypto::{HistorySecret, MlsCommitBundle};
99

1010
use crate::{ClientId, CommitBundle, CoreCryptoFfi, CoreCryptoResult, HistorySecret as HistorySecretFfi};
1111

12-
/// MLS transport may or may not succeeed; this response indicates to CC the outcome of the transport attempt.
12+
/// MLS transport may or may not succeeed; this response indicates to CC the
13+
/// outcome of the transport attempt.
1314
#[derive(Debug, Clone, PartialEq, Eq, uniffi::Enum)]
1415
pub enum MlsTransportResponse {
1516
/// The message was accepted by the distribution service
1617
Success,
1718
/// A client should have consumed all incoming messages before re-trying.
1819
Retry,
19-
/// The message was rejected by the delivery service and there's no recovery.
20+
/// The message was rejected by the delivery service and there's no
21+
/// recovery.
2022
Abort {
2123
/// Why was this message rejected
2224
reason: String,
@@ -48,8 +50,9 @@ impl From<MlsTransportResponse> for core_crypto::MlsTransportResponse {
4850
}
4951
}
5052

51-
/// Used by core crypto to send commits or application messages to the delivery service.
52-
/// This trait must be implemented before calling any functions that produce commits.
53+
/// Used by core crypto to send commits or application messages to the delivery
54+
/// service. This trait must be implemented before calling any functions that
55+
/// produce commits.
5356
#[uniffi::export(with_foreign)]
5457
#[cfg_attr(target_family = "wasm", async_trait::async_trait(?Send))]
5558
#[cfg_attr(not(target_family = "wasm"), async_trait::async_trait)]

0 commit comments

Comments
 (0)