Simplify MegolmV1AesSha2Content construction
This commit is contained in:
parent
e04ed242fc
commit
26850dbafb
@ -67,6 +67,9 @@ impl CiphertextInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The payload for `EncryptedEvent` using the *m.megolm.v1.aes-sha2* algorithm.
|
/// The payload for `EncryptedEvent` using the *m.megolm.v1.aes-sha2* algorithm.
|
||||||
|
///
|
||||||
|
/// To createn an instance of this type, first create a `MegolmV1AesSh2ContentInit` and convert it
|
||||||
|
/// via `MegolmV1AesSha2Content::from` / `.into()`.
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub struct MegolmV1AesSha2Content {
|
pub struct MegolmV1AesSha2Content {
|
||||||
@ -83,14 +86,6 @@ pub struct MegolmV1AesSha2Content {
|
|||||||
pub session_id: String,
|
pub session_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MegolmV1AesSha2Content {
|
|
||||||
/// Creates a new `MegolmV1AesSha2Content` from the given init struct.
|
|
||||||
pub fn new(init: MegolmV1AesSha2ContentInit) -> Self {
|
|
||||||
let MegolmV1AesSha2ContentInit { ciphertext, sender_key, device_id, session_id } = init;
|
|
||||||
Self { ciphertext, sender_key, device_id, session_id }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Mandatory initial set of fields of `MegolmV1AesSha2Content`.
|
/// Mandatory initial set of fields of `MegolmV1AesSha2Content`.
|
||||||
///
|
///
|
||||||
/// This struct will not be updated even if additional fields are added to `MegolmV1AesSha2Content`
|
/// This struct will not be updated even if additional fields are added to `MegolmV1AesSha2Content`
|
||||||
@ -110,6 +105,14 @@ pub struct MegolmV1AesSha2ContentInit {
|
|||||||
pub session_id: String,
|
pub session_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<MegolmV1AesSha2ContentInit> for MegolmV1AesSha2Content {
|
||||||
|
/// Creates a new `MegolmV1AesSha2Content` from the given init struct.
|
||||||
|
fn from(init: MegolmV1AesSha2ContentInit) -> Self {
|
||||||
|
let MegolmV1AesSha2ContentInit { ciphertext, sender_key, device_id, session_id } = init;
|
||||||
|
Self { ciphertext, sender_key, device_id, session_id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use matches::assert_matches;
|
use matches::assert_matches;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user