Add strum::ParseError variant to DeserializationError
This commit is contained in:
parent
9861aa20c8
commit
810bf56874
@ -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]
|
||||
|
@ -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),*
|
||||
}
|
||||
|
11
src/error.rs
11
src/error.rs
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user