Skip to content

Commit

Permalink
crypto: add some more documentation to DeviceKeys
Browse files Browse the repository at this point in the history
This confused me for a while, so I thought more documentation might help.
  • Loading branch information
richvdh committed Jan 16, 2025
1 parent f231c74 commit 2bd8c56
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/matrix-sdk-crypto/src/types/device_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ use super::{EventEncryptionAlgorithm, Signatures};
/// Specification, encapsulating essential elements such as the public device
/// identity keys.
///
/// See also [`ruma::encryption::DeviceKeys`] which is similar, but slightly
/// less comprehensive (it lacks some fields, and the `keys` are represented as
/// base64 strings rather than type-safe [`DeviceKey`]s). We always use this
/// struct to build `/keys/upload` requests and to deserialize `/keys/query`
/// responses.
///
/// [device_keys_spec]: https://spec.matrix.org/v1.10/client-server-api/#_matrixclientv3keysupload_devicekeys
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
#[serde(try_from = "DeviceKeyHelper", into = "DeviceKeyHelper")]
Expand Down Expand Up @@ -190,6 +196,8 @@ impl From<Ed25519PublicKey> for DeviceKey {
}
}

/// A de/serialization helper for [`DeviceKeys`] which maps the `keys` to/from
/// [`DeviceKey`]s.
#[derive(Clone, Debug, Deserialize, Serialize)]
struct DeviceKeyHelper {
pub user_id: OwnedUserId,
Expand Down

0 comments on commit 2bd8c56

Please sign in to comment.