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 acrate::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
ai64
integer asDateTime
anddeserialize
ai64
integer fromDateTime
. - 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 acrate::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§
- Human
Readable - Wrapping a type in
HumanReadable
signals to the BSON serde integration that it and all recursively contained types should be handled as ifSerializerOptions::human_readable
andDeserializerOptions::human_readable
are set totrue
. - Utf8
Lossy Deserialization - 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.