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

RUST-1764 Add HumanReadable convenience wrapper #471

Merged
merged 4 commits into from
Apr 5, 2024

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Apr 4, 2024

RUST-1764

This wrapper removes the need for the human_readable_serialization option for Collection and provides more granular control as well. There could hypothetically also be a use for a corresponding NonHumanReadable wrapper but I'd prefer to wait on adding that until someone asks for it.

@abr-egn
Copy link
Contributor Author

abr-egn commented Apr 4, 2024

IMO, we should also remove the option from [De]SerializerOptions but that'll have to wait for BSON 3.0. If that makes sense to you I'll add deprecation warnings on those and file a ticket for the removal.

@abr-egn abr-egn marked this pull request as draft April 4, 2024 16:25
@@ -454,12 +458,16 @@ impl<'de, 'a> serde::de::Deserializer<'de> for &'a mut Deserializer<'de> {

self.deserialize_next(visitor, DeserializerHint::RawBson)
}
HUMAN_READABLE_NEWTYPE => {
self.human_readable = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be an issue when a HumanReadable<T> is nested in a struct with non-wrapped types following it? e.g.

struct Test {
    human_readable: HumanReadable<Document>,
    non_human_readable: Document,
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! I've fixed the logic and updated the test to flag that kind of failure.

@isabelatkinson
Copy link
Contributor

IMO, we should also remove the option from [De]SerializerOptions but that'll have to wait for BSON 3.0. If that makes sense to you I'll add deprecation warnings on those and file a ticket for the removal.

SGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants