Skip to content

RUST-1748 Refactor BSON DateTime serde converters using serde_conv_doc macro #570

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

Merged
merged 19 commits into from
Jul 16, 2025

Conversation

JamieTsai1024
Copy link
Collaborator

@JamieTsai1024 JamieTsai1024 commented Jul 8, 2025

Refactor all BSON DateTime serde helpers to use serde_conv_doc

  • To verify locally that the Rustdocs feature flags are included on modules and structs, prefix the cargo doc command with RUSTDOCFLAGS="--cfg docsrs":
    RUSTDOCFLAGS="--cfg docsrs" cargo doc --open
Old New
bson_datetime_as_rfc3339_string datetime::AsRfc3339String (DateTime → u32)
rfc3339_string_as_bson_datetime datetime::FromRfc3339String (String → DateTime)
chrono_datetime_as_bson_datetime datetime::FromChrono04DateTime (chrono::DateTime → DateTime)
i64_as_bson_datetime datetime::FromI64 (i64 → DateTime)
time_0_3_offsetdatetime_as_bson_datetimetime-0_3 datetime::FromTime03OffsetDateTime (time::OffsetDateTime→ DateTime)

Previously:

  • Rewrote serde converters as structs with SerializeAs and DeserializeAs traits to support Optional and Vector conversions in PR #559
  • Refactored struct implementation to use serde_conv macro in PR #566

@JamieTsai1024 JamieTsai1024 marked this pull request as ready for review July 8, 2025 15:21
@JamieTsai1024 JamieTsai1024 requested a review from a team as a code owner July 8, 2025 15:21
@JamieTsai1024 JamieTsai1024 requested a review from kevinAlbs July 8, 2025 17:37
kevinAlbs
kevinAlbs previously approved these changes Jul 10, 2025
Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

LGTM, but I request waiting on @isabelatkinson or @abr-egn to review before merging.

Copy link
Contributor

@abr-egn abr-egn left a comment

Choose a reason for hiding this comment

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

Overall looks good, just one minor comment.

@JamieTsai1024 JamieTsai1024 requested a review from abr-egn July 14, 2025 13:31
abr-egn
abr-egn previously approved these changes Jul 14, 2025
Copy link
Contributor

@abr-egn abr-egn left a comment

Choose a reason for hiding this comment

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

LGTM!

@JamieTsai1024 JamieTsai1024 requested a review from abr-egn July 15, 2025 03:46
a_deserialized.date_optional_none, None,
"Expected deserialized date_optional_none to be None."
);
#[serde_as]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

reordered tests based on definitions in serde_helpers.rs

@JamieTsai1024 JamieTsai1024 merged commit f14d6d1 into mongodb:main Jul 16, 2025
11 checks passed
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.

4 participants