From 25fbd64b968c5d5088c07750aaa4873e072831b0 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 16 Aug 2024 06:22:38 +0000 Subject: [PATCH] fix str to mxc conversion; add convenience OwnedMxcUri conversion Signed-off-by: Jason Volk --- crates/ruma-common/src/identifiers/mxc_uri.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/ruma-common/src/identifiers/mxc_uri.rs b/crates/ruma-common/src/identifiers/mxc_uri.rs index 33e99c6a..d1513bf6 100644 --- a/crates/ruma-common/src/identifiers/mxc_uri.rs +++ b/crates/ruma-common/src/identifiers/mxc_uri.rs @@ -84,6 +84,16 @@ impl<'a> TryFrom<&'a str> for Mxc<'a> { type Error = MxcUriError; fn try_from(s: &'a str) -> Result { + let s: &MxcUri = s.into(); + s.try_into() + } +} + +impl<'a> TryFrom<&'a OwnedMxcUri> for Mxc<'a> { + type Error = MxcUriError; + + fn try_from(s: &'a OwnedMxcUri) -> Result { + let s: &MxcUri = s.as_ref(); s.try_into() } }