Skip to content

Conversation

@JamieTsai1024
Copy link
Owner

@JamieTsai1024 JamieTsai1024 commented Jul 8, 2025

This PR was split into smaller PRs for review by unsigned (u32, u64), ObjectId (object_id), and UUID (uuid_1)

Original PR:

Converted unsigned (u32, u64) and UUID (uuid_1) converter functions in src/serde_helpers.rs to use serde_conv macro for serializing and deserializing optional and vector fields with serde_with.

  • Added tests for <T>, Option<T>, and Vec<T> fields (de)serialized using structs
  • Added documentation for modules and structs
  • Reordered tests to match ordering in serde_helpers
  • Made tests more succinct for deserializing structs and serializing *_optional_some structs
Old New
timestamp_as_u32 u32::FromTimestamp (Timestamp → u32)
u32_as_timestamp u32::AsTimestamp (u32 → Timestamp)
u32_as_f64 u32::AsF64 (u32 → f64)
serialize_u32_as_i32 u32::AsI32 (u32 → i32)
serialize_u32_as_i64 u32::AsI64 (u32 → i64)
u64_as_f64 u64::AsF64 (u64 → f64)
serialize_u64_as_i32 u64::AsI32 (u64 → i32)
serialize_u64_as_i64 u64::AsI64 (u64 → i64)
uuid_1_as_binary uuid_1::AsBinary (UUID → Binary)
uuid_1_as_c_sharp_legacy_binary uuid_1::AsCSharpLegacyBinary (UUID → Binary in the legacy C# driver UUID format)
uuid_1_as_java_legacy_binary uuid_1::AsJavaLegacyBinary (UUID → Binary in the legacy Java driver UUID format)
uuid_1_as_python_legacy_binary uuid_1::AsPythonLegacyBinary (UUID → Binary in the legacy Python driver UUID format)

Previously:

  • Rewrote serde converters as structs with SerializeAs and DeserializeAs traits to support Optional and Vector conversions in PR #559
  • Adapted serde_conv macro to support Rustdocs, refactored all ObjectId converters in PR #566
  • Refactored all DateTime converters PR #570

@JamieTsai1024 JamieTsai1024 changed the base branch from main to RUST-1748-serde_conv-2 July 8, 2025 20:17
@JamieTsai1024 JamieTsai1024 force-pushed the RUST-1748-serde_conv-3 branch from 4e4291e to 1db7343 Compare July 14, 2025 15:22
@JamieTsai1024 JamieTsai1024 changed the title RUST-1748 Convert remaining serde helpers to use serde_conv RUST-1748 Convert unsigned serde helpers to use serde_conv Jul 14, 2025
#[test]
fn test_unsigned_helpers() {
#[cfg(feature = "serde_with-3")]
fn test_oid_helpers() {
Copy link
Owner Author

Choose a reason for hiding this comment

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

moved oid tests to match order of structs in serde_helpers.rs

}

#[test]
fn test_unsigned_helpers() {
Copy link
Owner Author

Choose a reason for hiding this comment

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

new unsigned tests replaces this test

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.

3 participants