New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extract::Path
doesn't work with types using serde::Deserializer::deserialize_any
#1678
Comments
extract::Path
doesn't work with types using serde::de::Deserializer::deserialize_any
extract::Path
doesn't work with types using serde::Deserializer::deserialize_any
What would such an implementation look like? Afaik URL params aren't a self describing format so when you encounter some key/value pair how do you know what to deserialize that into? I check and the |
I think if we support it, |
The playground doesn't enable the right Cargo.toml[package]
name = "test123"
version = "0.1.0"
edition = "2021"
[dependencies]
serde = { version = "1", features = ["derive"] }
time = { version = "0.3", features = ["serde-human-readable", "parsing"] }
serde_urlencoded = "0.7" main.rsuse serde::Deserialize;
use time::Date;
fn main() {
#[derive(Debug, Deserialize)]
struct Stuff {
date: Date,
}
let deserialized: Stuff = serde_urlencoded::from_str("date=2022-01-01").unwrap();
println!("{deserialized:?}");
} stdout
|
I think the more interesting question for |
It seems |
Feature Request
Motivation
PathDeserializer
doesn't supportdeserialize_any
1 so it doesn't work with things liketime::Date
2Proposal
Add support for
deserialize_any
. I might be able to look into it in the following days.Alternatives
Create a wrapper around the type and force it to use a specific deserializer
Footnotes
https://github.com/tokio-rs/axum/blob/87a80ec47bfd2c39ac4ea3d1acffb5d1ff540f63/axum/src/extract/path/de.rs#L59 ↩
https://github.com/time-rs/time/blob/d97594b9f5cfeab0335c16687e26a8b51c56a526/time/src/serde/mod.rs#L124 ↩
The text was updated successfully, but these errors were encountered: