Skip to content

RUST-1748 Convert unsigned serde helpers to use serde_conv #575

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 61 commits into from
Jul 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
a54433e
Refactor BSON DateTime serde converters using serde_conv_doc macro
JamieTsai1024 Jul 8, 2025
a51f29e
Refactor OffsetDateTime and i64 to DateTime helpers to use serde_conv
JamieTsai1024 Jul 8, 2025
03e9a51
Refactor type converters betweem timestamp and u32 with serde_conv
JamieTsai1024 Jul 9, 2025
f1577fd
Refactor u32 and u64 to f64 converters to use serde_conv
JamieTsai1024 Jul 9, 2025
b8ad904
Rename u32 module to timestamp
JamieTsai1024 Jul 9, 2025
a1ad2de
Clean up remaining u32_as_timestamp converter
JamieTsai1024 Jul 9, 2025
5529ec8
Fix struct capitalization
JamieTsai1024 Jul 10, 2025
a7c182a
Refactor unsigned (u32, u64) to signed (i32, i64) converters using se…
JamieTsai1024 Jul 10, 2025
693faa8
Consolidate module names under u32 and u64
JamieTsai1024 Jul 10, 2025
a9873d3
Consolidate module names under u32 and u64
JamieTsai1024 Jul 10, 2025
b9b08cf
Refactor uuid to binary converter to use serde_conv
JamieTsai1024 Jul 11, 2025
1ccea32
Reorder tests based on serde_helpers ordering
JamieTsai1024 Jul 11, 2025
1db7343
Refactor uuid to legacy binary converters using serde_conv
JamieTsai1024 Jul 11, 2025
2298c43
Remove bson from datetime helpers module name
JamieTsai1024 Jul 14, 2025
7cdc3d9
Add RFC 3339 format to error messages
JamieTsai1024 Jul 14, 2025
76349a0
Fix typo
JamieTsai1024 Jul 14, 2025
e9b14b8
Refactor DateTime FromI64 and FromTime03OffsetDateTime using serde_co…
JamieTsai1024 Jul 14, 2025
212ea0b
Add rustdoc comments to module and structs
JamieTsai1024 Jul 14, 2025
03027d1
Switch from clone through to_owned() to dereference
JamieTsai1024 Jul 14, 2025
7077c0b
Rename bson_datetime module to datetime
JamieTsai1024 Jul 14, 2025
ebe3a99
Remove extra rustdocs ///
JamieTsai1024 Jul 14, 2025
9f41ee6
Add DateTime import to fix lint on rustdocs
JamieTsai1024 Jul 14, 2025
e6b69c5
Merge branch 'RUST-1748-serde_conv-2' into RUST-1748-serde_conv-3
JamieTsai1024 Jul 14, 2025
2d26b59
Remove DateTime import for rustdocs to avoid clippy warning
JamieTsai1024 Jul 14, 2025
d3d9a95
Add missing conditional compilation to OffsetDateTime struct
JamieTsai1024 Jul 14, 2025
e1e4dae
Merge branch 2 into branch 3
JamieTsai1024 Jul 14, 2025
ae2b0a4
Fix rustdoc imports
JamieTsai1024 Jul 14, 2025
3a0e345
Update rustdocs phrasing and improve struct naming for Chrono04DateTime
JamieTsai1024 Jul 14, 2025
f527aff
Split tests for DateTime
JamieTsai1024 Jul 14, 2025
c14f554
Merge branch 'RUST-1748-serde_conv-2' into RUST-1748-serde_conv-3
JamieTsai1024 Jul 14, 2025
f834214
Add back deleted u32 tests from merge
JamieTsai1024 Jul 14, 2025
ec82af4
Fix datetime rustdoc comments from merge
JamieTsai1024 Jul 14, 2025
47cbddd
Update rustdoc comments
JamieTsai1024 Jul 14, 2025
fe5b5e4
clippy test: revert FromTime03OffsetDateTime to FromTimeOffsetDateTime
JamieTsai1024 Jul 14, 2025
ca6f68f
Rename FromTime03OffsetDateTime
JamieTsai1024 Jul 14, 2025
b85d7d0
Merge branch 'RUST-1748-serde_conv-2' into RUST-1748-serde_conv-3
JamieTsai1024 Jul 14, 2025
53090e9
Revert all UUID changes (separate to another PR)
JamieTsai1024 Jul 14, 2025
f0c3833
Fix rustdoc import
JamieTsai1024 Jul 14, 2025
00a4f9c
Copy documentation and test changes for ObjectId
JamieTsai1024 Jul 14, 2025
3103c27
Try uncommenting conditional compilation on rustdoc comments
JamieTsai1024 Jul 15, 2025
6f74ead
Undo uncommenting rustdocs
JamieTsai1024 Jul 15, 2025
a3dd1b8
Fix clippy attempt - move conditional compilation attribute
JamieTsai1024 Jul 15, 2025
f81dfd2
Revert all ObjectId changes (separate to another PR)
JamieTsai1024 Jul 15, 2025
d3eb97e
Revert "Revert all ObjectId changes (separate to another PR)"
JamieTsai1024 Jul 15, 2025
60b6c4f
Move #[cfg(feature = serde_with-3)] attribute to test function
JamieTsai1024 Jul 15, 2025
d91ba76
Break tests into smaller functions
JamieTsai1024 Jul 15, 2025
de0b400
Remove whitespace diffs
JamieTsai1024 Jul 15, 2025
844b50c
Merge branch 'RUST-1748-serde_conv-2' into RUST-1748-serde_conv-3
JamieTsai1024 Jul 15, 2025
e9334c5
Merge branch 'RUST-1748-serde_conv-3' into RUST-1748-serde_conv-3.5
JamieTsai1024 Jul 15, 2025
6d4951c
Fix whitespace
JamieTsai1024 Jul 15, 2025
5ca198f
Fix rustdocs whitespace
JamieTsai1024 Jul 15, 2025
94526df
Update rustdoc imports
JamieTsai1024 Jul 15, 2025
1b5a9ca
Revert ObjectId changes from RUST-1748-serde_conv-3.5
JamieTsai1024 Jul 17, 2025
aa44139
Merge branch 'main' into RUST-1748-serde_conv-3-play
JamieTsai1024 Jul 17, 2025
2e27c2d
Fix failing tests - reorder attributes on TimestampBody struct
JamieTsai1024 Jul 17, 2025
6d733d7
Fix rustdocs formatting
JamieTsai1024 Jul 17, 2025
047cb04
Revert serialize_u32_as_i64 serde_with replacement
JamieTsai1024 Jul 17, 2025
9294f7c
Move serialize_u32_as_i64 to extjson/models
JamieTsai1024 Jul 17, 2025
7df4760
Move u32 to/from Timestamp to timestamp module
JamieTsai1024 Jul 18, 2025
c9a6ee7
Use from instead of as for type converters
JamieTsai1024 Jul 18, 2025
c97ea9d
Add cfg serde_with
JamieTsai1024 Jul 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/extjson/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ use serde::{
de::{Error as _, Unexpected},
Deserialize,
Serialize,
Serializer,
};
use std::borrow::Cow;
use std::{borrow::Cow, result::Result as StdResult};

use crate::{
base64,
Expand Down Expand Up @@ -217,13 +218,18 @@ pub(crate) struct Timestamp {
body: TimestampBody,
}

/// Serializes a u32 as an i64.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved this helper from src/serde_helpers.rs. Its use in the Timestamp serializer cannot be replaced with the new u32::AsI64 implementation since it relies on the optional dependency serde_with (behind serde_with-3 feature flag).

fn serialize_u32_as_i64<S: Serializer>(val: &u32, serializer: S) -> StdResult<S::Ok, S::Error> {
serializer.serialize_i64(*val as i64)
}

#[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub(crate) struct TimestampBody {
#[serde(serialize_with = "crate::serde_helpers::serialize_u32_as_i64")]
#[serde(serialize_with = "serialize_u32_as_i64")]
pub(crate) t: u32,

#[serde(serialize_with = "crate::serde_helpers::serialize_u32_as_i64")]
#[serde(serialize_with = "serialize_u32_as_i64")]
pub(crate) i: u32,
}

Expand Down
Loading