pub fn to_document<T: ?Sized>(value: &T) -> Result<Document> where
    T: Serialize
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.