diff --git a/crates/ruma-identifiers/src/matrix_uri.rs b/crates/ruma-identifiers/src/matrix_uri.rs index 0e1ae41f..20d6055d 100644 --- a/crates/ruma-identifiers/src/matrix_uri.rs +++ b/crates/ruma-identifiers/src/matrix_uri.rs @@ -1,6 +1,6 @@ //! Matrix URIs. -use std::{convert::TryFrom, fmt}; +use std::{convert::TryFrom, fmt, str::FromStr}; use percent_encoding::{percent_decode_str, percent_encode, AsciiSet, CONTROLS}; use ruma_identifiers_validation::{ @@ -306,6 +306,14 @@ impl TryFrom<&str> for MatrixToUri { } } +impl FromStr for MatrixToUri { + type Err = Error; + + fn from_str(s: &str) -> Result { + Self::parse(s) + } +} + /// The intent of a Matrix URI. #[derive(Clone, Debug, PartialEq, Eq)] #[non_exhaustive] @@ -474,6 +482,14 @@ impl TryFrom<&str> for MatrixUri { } } +impl FromStr for MatrixUri { + type Err = Error; + + fn from_str(s: &str) -> Result { + Self::parse(s) + } +} + #[cfg(test)] mod tests { use matches::assert_matches;