api: Move UnknownVersionError into error module

This commit is contained in:
Jonathan de Jong 2022-02-08 16:38:24 +01:00 committed by GitHub
parent 1e900ab58c
commit fe337f8d5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 14 deletions

View File

@ -221,3 +221,16 @@ pub enum HeaderDeserializationError {
#[error("Missing header `{0}`")]
MissingHeader(String),
}
/// An error that happens when Ruma cannot understand a Matrix version.
#[derive(Debug)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct UnknownVersionError;
impl fmt::Display for UnknownVersionError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Version string was unknown.")
}
}
impl StdError for UnknownVersionError {}

View File

@ -214,7 +214,7 @@ pub mod exports {
pub use serde_json;
}
use error::{FromHttpRequestError, FromHttpResponseError, IntoHttpError};
use error::{FromHttpRequestError, FromHttpResponseError, IntoHttpError, UnknownVersionError};
/// An enum to control whether an access token should be added to outgoing requests
#[derive(Clone, Copy, Debug)]
@ -487,19 +487,6 @@ pub enum MatrixVersion {
V1_2,
}
/// An error that happens when Ruma cannot understand a Matrix version.
#[derive(Debug)]
#[cfg_attr(not(feature = "unstable-exhaustive-types"), non_exhaustive)]
pub struct UnknownVersionError;
impl Display for UnknownVersionError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Version string was unknown.")
}
}
impl StdError for UnknownVersionError {}
impl TryFrom<&str> for MatrixVersion {
type Error = UnknownVersionError;