api: Add impl FromStr for MatrixVersion

Enables `str.parse::<MatrixVersion>()`.
This commit is contained in:
Jonas Platte 2022-02-09 12:05:18 +01:00
parent ae4c9243cb
commit 1e94c3cd39
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67

View File

@ -1,6 +1,7 @@
use std::{ use std::{
convert::TryFrom, convert::TryFrom,
fmt::{self, Display}, fmt::{self, Display},
str::FromStr,
}; };
use http::Method; use http::Method;
@ -111,6 +112,14 @@ impl TryFrom<&str> for MatrixVersion {
} }
} }
impl FromStr for MatrixVersion {
type Err = UnknownVersionError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Self::try_from(s)
}
}
impl MatrixVersion { impl MatrixVersion {
/// Checks whether a version is compatible with another. /// Checks whether a version is compatible with another.
/// ///