Function bson::to_document
source · pub fn to_document<T>(value: &T) -> Result<Document>where
T: Serialize + ?Sized,
Expand description
Encode a T
Serializable into a BSON Document
.
The Serializer
used by this function presents itself as human readable, whereas the
one used in to_vec
does not. This means that this function will produce different BSON than
to_vec
for types that change their serialization output depending on whether
the format is human readable or not. To serialize to a Document
with a serializer that
presents itself as not human readable, use to_document_with_options
with
SerializerOptions::human_readable
set to false.