Skip to content

Commit aa25c26

Browse files
RUST-1748 Apply formatting changes to ObjectId (#578)
1 parent 3b34ff9 commit aa25c26

File tree

2 files changed

+190
-243
lines changed

2 files changed

+190
-243
lines changed

src/serde_helpers.rs

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,27 @@ pub use uuid_1_as_python_legacy_binary::{
3131
serialize as serialize_uuid_1_as_python_legacy_binary,
3232
};
3333

34+
/// Type converters for serializing and deserializing [`crate::oid::ObjectId`] using
35+
/// [`serde_with::serde_as`].
36+
///
37+
/// ## Available converters
38+
/// - [`object_id::AsHexString`] — converts an [`crate::oid::ObjectId`] to and from a hex string.
39+
/// - [`object_id::FromHexString`] — converts a hex string to and from an [`crate::oid::ObjectId`].
3440
#[cfg(feature = "serde_with-3")]
41+
#[cfg_attr(docsrs, doc(cfg(feature = "serde_with-3")))]
3542
pub mod object_id {
3643
use crate::{macros::serde_conv_doc, oid::ObjectId};
3744
use serde::{Deserialize, Deserializer, Serialize, Serializer};
3845
use serde_with::{DeserializeAs, SerializeAs};
3946

4047
serde_conv_doc!(
41-
/// Contains functions to serialize an ObjectId as a hex string and deserialize an
42-
/// ObjectId from a hex string
48+
/// Converts an [`ObjectId`] to and from a hex string.
4349
/// ```rust
4450
/// # #[cfg(feature = "serde_with-3")]
45-
/// {
46-
/// # use serde::{Serialize, Deserialize};
47-
/// # use bson::serde_helpers::object_id;
48-
/// # use serde_with::serde_as;
49-
/// # use bson::oid::ObjectId;
51+
/// # {
52+
/// use bson::{serde_helpers::object_id, oid::ObjectId};
53+
/// use serde::{Serialize, Deserialize};
54+
/// use serde_with::serde_as;
5055
/// #[serde_as]
5156
/// #[derive(Serialize, Deserialize)]
5257
/// struct Item {
@@ -66,14 +71,13 @@ pub mod object_id {
6671
);
6772

6873
serde_conv_doc!(
69-
/// Contains functions to serialize a hex string as an ObjectId and deserialize a
70-
/// hex string from an ObjectId
74+
/// Converts a hex string to and from an [`ObjectId`].
7175
/// ```rust
7276
/// # #[cfg(feature = "serde_with-3")]
73-
/// {
74-
/// # use serde::{Serialize, Deserialize};
75-
/// # use bson::serde_helpers::object_id;
76-
/// # use serde_with::serde_as;
77+
/// # {
78+
/// use bson::serde_helpers::object_id;
79+
/// use serde::{Serialize, Deserialize};
80+
/// use serde_with::serde_as;
7781
/// #[serde_as]
7882
/// #[derive(Serialize, Deserialize)]
7983
/// struct Item {

0 commit comments

Comments
 (0)