iron / iron/params

Reconsider "deserialization" (currently done through Serde)

Open
#18 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
34
Forks
29
PR merge metrics
No merged PRs in 30d

Description

I recently coded Serde compatibility, so that `params::Value` could be transformed into any type that implements `serde::Deserialize`. This is especially handy for unpacking parameters into strictly typed `struct`s. Serde was chosen for this mechanic because it provides a really handy compiler macro through `#[derive(Deserialize)]`, so essentially the library user doesn't have to implement `params::FromValue` themself. Unfortunately, this is a hackish solution because Serde doesn't allow "passing through" custom types, such as `params::File`. This is completely understandable; we're not actually doing _deserialization_ here, just _transformation_.

Should a compiler plugin be coded that allows for something like `#[derive(ParamsFromValue)]`?

It should be noted that the `serde` feature should be completely dropped from `params`. 😭

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.