Add strum::ParseError variant to DeserializationError

This commit is contained in:
Jonas Platte 2020-02-18 20:58:29 +01:00
parent 9861aa20c8
commit 810bf56874
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
3 changed files with 13 additions and 5 deletions

View File

@ -23,6 +23,7 @@ ruma-identifiers = { version = "0.14.1", optional = true }
serde = { version = "1.0.104", features = ["derive"], optional = true }
serde_json = "1.0.47"
serde_urlencoded = "0.6.1"
strum = "0.17.1"
url = { version = "2.1.1", optional = true }
[dev-dependencies]

View File

@ -353,11 +353,7 @@ impl ToTokens for Request {
quote! {
/// Data in the request path.
#[derive(
Debug,
ruma_api::exports::serde::Deserialize,
ruma_api::exports::serde::Serialize,
)]
#[derive(Debug)]
struct RequestPath {
#(#fields),*
}

View File

@ -194,6 +194,9 @@ pub enum DeserializationError {
Json(serde_json::Error),
Query(serde_urlencoded::de::Error),
Ident(ruma_identifiers::Error),
// String <> Enum conversion failed. This can currently only happen in path
// segment deserialization
Strum(strum::ParseError),
}
impl Display for DeserializationError {
@ -202,6 +205,7 @@ impl Display for DeserializationError {
DeserializationError::Json(err) => Display::fmt(err, f),
DeserializationError::Query(err) => Display::fmt(err, f),
DeserializationError::Ident(err) => Display::fmt(err, f),
DeserializationError::Strum(err) => Display::fmt(err, f),
}
}
}
@ -227,6 +231,13 @@ impl From<ruma_identifiers::Error> for DeserializationError {
}
}
#[doc(hidden)]
impl From<strum::ParseError> for DeserializationError {
fn from(err: strum::ParseError) -> Self {
Self::Strum(err)
}
}
#[doc(hidden)]
impl From<std::convert::Infallible> for DeserializationError {
fn from(err: std::convert::Infallible) -> Self {