From 21837d6b8d95c2677130236c5d6280233f0459a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 30 Jul 2020 10:56:14 +0200 Subject: [PATCH] ruma-events: Implement TryFrom to for MSasV1Content. --- ruma-events/src/key/verification/start.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ruma-events/src/key/verification/start.rs b/ruma-events/src/key/verification/start.rs index 54c0ef8d..479a2a26 100644 --- a/ruma-events/src/key/verification/start.rs +++ b/ruma-events/src/key/verification/start.rs @@ -1,6 +1,6 @@ //! Types for the *m.key.verification.start* event. -use std::collections::BTreeMap; +use std::{collections::BTreeMap, convert::TryFrom}; use ruma_events_macros::BasicEventContent; use ruma_identifiers::DeviceId; @@ -123,6 +123,15 @@ impl MSasV1Content { /// `MessageAuthenticationCode::HkdfHmacSha256`. /// * `short_authentication_string` does not include `ShortAuthenticationString::Decimal`. pub fn new(options: MSasV1ContentOptions) -> Result { + MSasV1Content::try_from(options) + } +} + +impl TryFrom for MSasV1Content { + type Error = InvalidInput; + + /// Creates a new `MSasV1Content` from the given init struct. + fn try_from(options: MSasV1ContentOptions) -> Result { if !options.key_agreement_protocols.contains(&KeyAgreementProtocol::Curve25519) && !options .key_agreement_protocols