Skip to content

RUST-1753: Add a utility HumanReadable wrapper #431

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

Closed
wants to merge 1 commit into from

Conversation

abr-egn
Copy link
Contributor

@abr-egn abr-egn commented Sep 7, 2023

RUST-1753

I propose that instead of adding an explicit option to Collection to force on human-readable [de]serialization, we provide a type wrapper that does the same thing. This should provide equivalent functionality (instead of setting opts.human_readable_serialization = true for a given Collection<Foo>, specify the type as Collection<HumanReadable<Foo>>), but means that we don't have to support checking the explicit option in every relevant code path for every method. Subjectively, I also find this cleaner :)

I put this in the bson::serde_helpers module because it's arguably independent of the driver; it's even arguably independent of bson, but I don't think we want to maintain another crate.

If we do decide to use this, the path forward would be:

  1. Put out a new release of the bson crate with these helpers.
  2. Update the driver to remove the option and consistently use binary [de]serialization; AFAICT this is mostly done already as part of the earlier work, it just needs the fix in fixing the find or delete serde inconsistency mongo-rust-driver#948.
  3. Put out a beta.1 release of the driver with those changes.

Copy link
Contributor

@isabelatkinson isabelatkinson left a comment

Choose a reason for hiding this comment

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

lgtm! i think we should add some docs/examples of how to use this in the driver but that can be part of step 2 :)

@abr-egn
Copy link
Contributor Author

abr-egn commented Sep 12, 2023

Unfortunately, writing tests for this shows that it doesn't work :( When serializing nested fields, a new serializer is constructed, and that doesn't have (and has no way of knowing about) the wrapper of the top-level serializer.

@abr-egn abr-egn closed this Sep 12, 2023
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