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

Handle Serde (de)serializer annotations in function wrappers #111

Open
arendjr opened this issue May 3, 2022 · 0 comments
Open

Handle Serde (de)serializer annotations in function wrappers #111

arendjr opened this issue May 3, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@arendjr
Copy link
Contributor

arendjr commented May 3, 2022

Some custom types rely on Serde annotations to specify custom (de)serializers. An example of this are the types from the time crate, where we use Serde's with annotation to specify they should be (de)serialized using RFC339 formatting.

Unfortunately, those annotations can only be used in field positions, such as struct and enum variant fields. This means this approach breaks down when passing the types directly as function arguments, for instance.

However, because our bindings inject wrapper functions anyway, we could theoretically make those wrappers aware of the annotations and call the correct (de)serializer when such an annotation is used on a type that is passed as an argument or returned as a value. This would shield our users from one more edge case, though the edge case of using such types as a generic argument remains.

For the time being, we recognize this issue exists and advise users to use newtypes to work around the issue. A warning is displayed when a user's protocol may run into these issues, as implemented in #110.

@arendjr arendjr added the enhancement New feature or request label May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant