Add serde_html_form to Error; use serde_core for greater abstraction.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-12-21 13:08:48 +00:00
parent e79b888367
commit 422802a9cf
4 changed files with 14 additions and 4 deletions

View File

@@ -418,6 +418,10 @@ version = "1.0"
default-features = false default-features = false
features = ["rc"] features = ["rc"]
[workspace.dependencies.serde_core]
version = "1.0"
default-features = false
[workspace.dependencies.serde_html_form] [workspace.dependencies.serde_html_form]
version = "0.2" version = "0.2"

View File

@@ -85,6 +85,8 @@ reqwest.workspace = true
ring.workspace = true ring.workspace = true
ruma.workspace = true ruma.workspace = true
sanitize-filename.workspace = true sanitize-filename.workspace = true
serde_core.workspace = true
serde_html_form.workspace = true
serde_json.workspace = true serde_json.workspace = true
serde_regex.workspace = true serde_regex.workspace = true
serde_yaml.workspace = true serde_yaml.workspace = true

View File

@@ -57,6 +57,10 @@ pub enum Error {
#[error(transparent)] #[error(transparent)]
Figment(#[from] figment::error::Error), Figment(#[from] figment::error::Error),
#[error(transparent)] #[error(transparent)]
HtmlFormDe(#[from] serde_html_form::de::Error),
#[error(transparent)]
HtmlFormSer(#[from] serde_html_form::ser::Error),
#[error(transparent)]
Http(#[from] http::Error), Http(#[from] http::Error),
#[error(transparent)] #[error(transparent)]
HttpHeader(#[from] http::header::InvalidHeaderValue), HttpHeader(#[from] http::header::InvalidHeaderValue),
@@ -91,6 +95,8 @@ pub enum Error {
#[error(transparent)] #[error(transparent)]
TypedHeader(#[from] axum_extra::typed_header::TypedHeaderRejection), TypedHeader(#[from] axum_extra::typed_header::TypedHeaderRejection),
#[error(transparent)] #[error(transparent)]
UrlParse(#[from] url::ParseError),
#[error(transparent)]
Yaml(#[from] serde_yaml::Error), Yaml(#[from] serde_yaml::Error),
// ruma/tuwunel // ruma/tuwunel

View File

@@ -1,13 +1,11 @@
use std::fmt::Display; use std::fmt::Display;
use serde::{de, ser};
use crate::Error; use crate::Error;
impl de::Error for Error { impl serde_core::de::Error for Error {
fn custom<T: Display + ToString>(msg: T) -> Self { Self::SerdeDe(msg.to_string().into()) } fn custom<T: Display + ToString>(msg: T) -> Self { Self::SerdeDe(msg.to_string().into()) }
} }
impl ser::Error for Error { impl serde_core::ser::Error for Error {
fn custom<T: Display + ToString>(msg: T) -> Self { Self::SerdeSer(msg.to_string().into()) } fn custom<T: Display + ToString>(msg: T) -> Self { Self::SerdeSer(msg.to_string().into()) }
} }