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

Use #[serde(remote = "Self")] to simplify serde impls #2287

Merged
merged 1 commit into from
Nov 16, 2022

Conversation

kangalio
Copy link
Collaborator

@kangalio kangalio commented Nov 16, 2022

In multiple places, serenity used manual Deserialize implementations because it had to intervene in the deserialization process. The actual intervention is almost always small, but in turn, the entire deserialization process had to be rewritten.

This PR changes applicable places to use the Deserialize derive instead with the #[serde(remote = "Self")] attribute. This attribute makes serde generate the deserialize+serialize methods as private inherent methods instead of as trait implementations. Therefore, a manual deserialization implementation can easily delegate to those inherent methods and implement their special behavior on top of them.

@github-actions github-actions bot added model Related to the `model` module. voice Related to the `voice` module and `serenity_voice_model` crate. labels Nov 16, 2022
@arqunis arqunis added the enhancement An improvement to Serenity. label Nov 16, 2022
@arqunis arqunis merged commit da0acdc into serenity-rs:next Nov 16, 2022
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Feb 28, 2023
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request May 18, 2023
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request May 30, 2023
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Sep 21, 2023
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Oct 17, 2023
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Oct 24, 2023
arqunis pushed a commit to arqunis/serenity that referenced this pull request Oct 24, 2023
arqunis pushed a commit to arqunis/serenity that referenced this pull request Oct 24, 2023
arqunis pushed a commit that referenced this pull request Dec 24, 2023
Specifically, the `members` field was being incorrectly deserialized. In
#2287, the logic for collecting the received array of members into a
hashmap was removed, meaning the deserializer now looked for a map
instead of a sequence, causing deserialization to fail. This PR adds
that logic back.

Closes #2666
mkrasnitski added a commit that referenced this pull request Dec 24, 2023
Specifically, the `members` field was being incorrectly deserialized. In
#2287, the logic for collecting the received array of members into a
hashmap was removed, meaning the deserializer now looked for a map
instead of a sequence, causing deserialization to fail. This PR adds
that logic back.

Closes #2666
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement to Serenity. model Related to the `model` module. voice Related to the `voice` module and `serenity_voice_model` crate.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants