diff --git a/crates/ruma-api/src/error.rs b/crates/ruma-api/src/error.rs index eba3a91c..bc215f0d 100644 --- a/crates/ruma-api/src/error.rs +++ b/crates/ruma-api/src/error.rs @@ -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 {} diff --git a/crates/ruma-api/src/lib.rs b/crates/ruma-api/src/lib.rs index 5003a192..643b378e 100644 --- a/crates/ruma-api/src/lib.rs +++ b/crates/ruma-api/src/lib.rs @@ -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;