Tagged enum in Query #1945
-
Hey 👋 We're working on creating a query parameter struct but one of the fields is (de)serialized as a tagged enum. So the code roughly looks like the following: #[serde(rename_all = "camelCase")]
pub struct CobsQuery {
pub page: Option<usize>,
pub per_page: Option<usize>,
pub state: Option<State>,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)]
#[serde(rename_all = "camelCase", tag = "status")]
pub enum State {
#[default]
Open,
Draft,
Archived,
Merged,
} We would hope to use the params like: We can change Thanks for any help you can provide! 😊 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Axum uses serde_urlencoded which I believe is limited in this regard. Try searching for issues in their repo. |
Beta Was this translation helpful? Give feedback.
-
If anyone else is looking, I came across this issue nox/serde_urlencoded#26 Going off the helpful comment here, it's possible to use |
Beta Was this translation helpful? Give feedback.
Axum uses serde_urlencoded which I believe is limited in this regard. Try searching for issues in their repo.