Expand description

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.

#[derive(Serialize, Deserialize)]
struct Item {
    #[serde(with = "timestamp_as_u32")]
    pub timestamp: Timestamp,
}

Functions

  • Deserializes a bson::Timestamp from a 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).