51
51
//!
52
52
//! ```toml
53
53
//! [dependencies]
54
- //! bson = "2.9 .0"
54
+ //! bson = "2.10 .0"
55
55
//! ```
56
56
//!
57
57
//! Note that if you are using `bson` through the `mongodb` crate, you do not need to specify it in
208
208
//! let redacted_bson = bson::to_bson(&person).unwrap();
209
209
//! ```
210
210
//!
211
- //! Any types that implement [`Serialize`](serde::Serialize) and [`Deserialize`](serde::Deserialize) can be used in this way. Doing so helps
212
- //! separate the "business logic" that operates over the data from the (de)serialization logic that
213
- //! translates the data to/from its serialized form. This can lead to more clear and concise code
214
- //! that is also less error prone.
211
+ //! Any types that implement [`Serialize`](serde::Serialize) and [`Deserialize`](serde::Deserialize)
212
+ //! can be used in this way. Doing so helps separate the "business logic" that operates over the
213
+ //! data from the (de)serialization logic that translates the data to/from its serialized form. This
214
+ //! can lead to more clear and concise code that is also less error prone.
215
215
//!
216
216
//! ## Working with datetimes
217
217
//!
218
218
//! The BSON format includes a datetime type, which is modeled in this crate by the
219
219
//! [`DateTime`] struct, and the
220
- //! [`Serialize`](serde::Serialize) and [`Deserialize`](serde::Deserialize) implementations for this struct produce and parse BSON datetimes
221
- //! when serializing to or deserializing from BSON. The popular crate [`chrono`](docs.rs/chrono)
222
- //! also provides a [`DateTime`] type, but its [`Serialize`](serde::Serialize) and [`Deserialize`](serde::Deserialize) implementations operate
220
+ //! [`Serialize`](serde::Serialize) and [`Deserialize`](serde::Deserialize) implementations for this
221
+ //! struct produce and parse BSON datetimes when serializing to or deserializing from BSON. The
222
+ //! popular crate [`chrono`](docs.rs/chrono) also provides a [`DateTime`] type, but its
223
+ //! [`Serialize`](serde::Serialize) and [`Deserialize`](serde::Deserialize) implementations operate
223
224
//! on strings instead, so when using it with BSON, the BSON datetime type is not used. To work
224
225
//! around this, the `chrono-0_4` feature flag can be enabled. This flag exposes a number of
225
- //! convenient conversions between [`bson::DateTime`](crate::DateTime) and [`chrono::DateTime`], including the
226
- //! [`serde_helpers::chrono_datetime_as_bson_datetime`]
227
- //! serde helper, which can be used to (de)serialize [`chrono::DateTime`]s to/from BSON datetimes, and
228
- //! the `From<chrono::DateTime>` implementation for [`Bson`], which allows [`chrono::DateTime`] values
229
- //! to be used in the `doc!` and `bson!` macros.
226
+ //! convenient conversions between [`bson::DateTime`](crate::DateTime) and [`chrono::DateTime`],
227
+ //! including the [`serde_helpers::chrono_datetime_as_bson_datetime`]
228
+ //! serde helper, which can be used to (de)serialize [`chrono::DateTime`]s to/from BSON datetimes,
229
+ //! and the `From<chrono::DateTime>` implementation for [`Bson`], which allows [`chrono::DateTime`]
230
+ //! values to be used in the `doc!` and `bson!` macros.
230
231
//!
231
232
//! e.g.
232
233
//! ``` rust
267
268
//!
268
269
//! ## Minimum supported Rust version (MSRV)
269
270
//!
270
- //! The MSRV for this crate is currently 1.64.0. This will be rarely be increased, and if it ever is,
271
- //! it will only happen in a minor or major version release.
271
+ //! The MSRV for this crate is currently 1.64.0. This will be rarely be increased, and if it ever
272
+ //! is, it will only happen in a minor or major version release.
272
273
273
274
#![ allow( clippy:: cognitive_complexity, clippy:: derive_partial_eq_without_eq) ]
274
275
#![ doc( html_root_url = "https://docs.rs/bson/2.6.0" ) ]
@@ -280,18 +281,40 @@ pub use self::{
280
281
bson:: { Array , Bson , DbPointer , Document , JavaScriptCodeWithScope , Regex , Timestamp } ,
281
282
datetime:: DateTime ,
282
283
de:: {
283
- from_bson, from_bson_with_options, from_document, from_document_with_options, from_reader,
284
- from_reader_utf8_lossy, from_slice, from_slice_utf8_lossy, Deserializer ,
284
+ from_bson,
285
+ from_bson_with_options,
286
+ from_document,
287
+ from_document_with_options,
288
+ from_reader,
289
+ from_reader_utf8_lossy,
290
+ from_slice,
291
+ from_slice_utf8_lossy,
292
+ Deserializer ,
285
293
DeserializerOptions ,
286
294
} ,
287
295
decimal128:: Decimal128 ,
288
296
raw:: {
289
- RawArray , RawArrayBuf , RawBinaryRef , RawBson , RawBsonRef , RawDbPointerRef , RawDocument ,
290
- RawDocumentBuf , RawJavaScriptCodeWithScope , RawJavaScriptCodeWithScopeRef , RawRegexRef ,
297
+ RawArray ,
298
+ RawArrayBuf ,
299
+ RawBinaryRef ,
300
+ RawBson ,
301
+ RawBsonRef ,
302
+ RawDbPointerRef ,
303
+ RawDocument ,
304
+ RawDocumentBuf ,
305
+ RawJavaScriptCodeWithScope ,
306
+ RawJavaScriptCodeWithScopeRef ,
307
+ RawRegexRef ,
291
308
} ,
292
309
ser:: {
293
- to_bson, to_bson_with_options, to_document, to_document_with_options, to_raw_document_buf,
294
- to_vec, Serializer , SerializerOptions ,
310
+ to_bson,
311
+ to_bson_with_options,
312
+ to_document,
313
+ to_document_with_options,
314
+ to_raw_document_buf,
315
+ to_vec,
316
+ Serializer ,
317
+ SerializerOptions ,
295
318
} ,
296
319
uuid:: { Uuid , UuidRepresentation } ,
297
320
} ;
0 commit comments