Module serde_helpers

Module serde_helpers 

Source
Expand description

Collection of helper functions for serializing to and deserializing from BSON using Serde

Modules§

bson_datetime_as_rfc3339_string
Contains functions to serialize a crate::DateTime as an RFC 3339 (ISO 8601) formatted string and deserialize a crate::DateTime from an RFC 3339 (ISO 8601) formatted string.
hex_string_as_object_id
Contains functions to serialize a hex string as an ObjectId and deserialize a hex string from an ObjectId
i64_as_bson_datetime
Contains functions to serialize a i64 integer as DateTime and deserialize a i64 integer from DateTime.
rfc3339_string_as_bson_datetime
Contains functions to serialize an RFC 3339 (ISO 8601) formatted string as a crate::DateTime and deserialize an RFC 3339 (ISO 8601) formatted string from a crate::DateTime.
timestamp_as_u32
Contains functions to serialize a bson::Timestamp as a u32 and deserialize a bson::Timestamp from a u32. The u32 should represent seconds since the Unix epoch. Serialization will return an error if the Timestamp has a non-zero increment.
u32_as_f64
Contains functions to serialize a u32 as an f64 (BSON double) and deserialize a u32 from an f64 (BSON double).
u32_as_timestamp
Contains functions to serialize a u32 as a bson::Timestamp and deserialize a u32 from a bson::Timestamp. The u32 should represent seconds since the Unix epoch.
u64_as_f64
Contains functions to serialize a u64 as an f64 (BSON double) and deserialize a u64 from an f64 (BSON double).

Structs§

HumanReadable
Wrapping a type in HumanReadable signals to the BSON serde integration that it and all recursively contained types should be handled as if SerializerOptions::human_readable and DeserializerOptions::human_readable are set to true.
Utf8LossyDeserialization
Wrapper type for deserializing BSON bytes with invalid UTF-8 sequences.

Functions§

deserialize_bson_datetime_from_rfc3339_string
Deserializes a crate::DateTime from an RFC 3339 formatted string.
deserialize_hex_string_from_object_id
Deserializes a hex string from an ObjectId.
deserialize_i64_from_bson_datetime
Deserializes a i64 integer from a DateTime.
deserialize_rfc3339_string_from_bson_datetime
Deserializes an ISO string from a DateTime.
deserialize_timestamp_from_u32
Deserializes a bson::Timestamp from a u32.
deserialize_u32_from_f64
Deserializes a u32 from an f64 (BSON double). Errors if an exact conversion is not possible.
deserialize_u32_from_timestamp
Deserializes a u32 from a bson::Timestamp.
deserialize_u64_from_f64
Deserializes a u64 from an f64 (BSON double). Errors if an exact conversion is not possible.
serialize_bson_datetime_as_rfc3339_string
Serializes a crate::DateTime as an RFC 3339 (ISO 8601) formatted string.
serialize_hex_string_as_object_id
Serializes a hex string as an ObjectId.
serialize_i64_as_bson_datetime
Serializes a i64 integer as a DateTime.
serialize_object_id_as_hex_string
Serializes an ObjectId as a hex string.
serialize_rfc3339_string_as_bson_datetime
Serializes an ISO string as a DateTime.
serialize_timestamp_as_u32
Serializes a bson::Timestamp as a u32. Returns an error if the conversion is lossy (i.e. the Timestamp has a non-zero increment).
serialize_u32_as_f64
Serializes a u32 as an f64 (BSON double).
serialize_u32_as_i32
Attempts to serialize a u32 as an i32. Errors if an exact conversion is not possible.
serialize_u32_as_i64
Serializes a u32 as an i64.
serialize_u32_as_timestamp
Serializes a u32 as a bson::Timestamp.
serialize_u64_as_f64
Serializes a u64 as an f64 (BSON double). Errors if an exact conversion is not possible.
serialize_u64_as_i32
Attempts to serialize a u64 as an i32. Errors if an exact conversion is not possible.
serialize_u64_as_i64
Attempts to serialize a u64 as an i64. Errors if an exact conversion is not possible.