Skip to content
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

[Suggest] Deserialize user-defined types including resource #2873

Open
cpunion opened this issue Dec 28, 2024 · 0 comments
Open

[Suggest] Deserialize user-defined types including resource #2873

cpunion opened this issue Dec 28, 2024 · 0 comments

Comments

@cpunion
Copy link

cpunion commented Dec 28, 2024

I have asked a question on the Rust Discord forum How to deserialize a custom type containing Arc<File> from a generic parameter?, and I've completed a crate https://github.com/cpunion/axum-params. It works, but could be improved.

As described in the post above, user-defined types that include an Arc<File> field can't be deserialized. The workaround is to deserialize the path and hold File(s) in a container to prevent it from being dropped.

In the serde documentation https://serde.rs/data-model.html#types, serde supports many types, but the limitation seems to be that the types must be convertible or contain primitive types. Not all types need to be serialized to/deserialized from bytes. In my case, it just needs to serialize/deserialize to a DOM, where some types just need to be cloned to the target. I think this satisfies Serialize/Deserialize, just not SerializeToBytes/DeserializeFromBytes.

Would this use case be considered?

@cpunion cpunion changed the title Deserialize user-defined types including resource [Suggest] Deserialize user-defined types including resource Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant