Function bson::from_bson_with_options

source ยท
pub fn from_bson_with_options<T>(
    bson: Bson,
    options: DeserializerOptions,
) -> Result<T>
Expand description

Deserialize a T from the provided Bson value, configuring the underlying deserializer with the provided options.

#[derive(Debug, Deserialize, PartialEq)]
struct MyData {
    a: String,
}

let bson = bson!({ "a": "hello" });
let options = DeserializerOptions::builder().human_readable(false).build();
let data: MyData = bson::from_bson_with_options(bson, options)?;
assert_eq!(data, MyData { a: "hello".to_string() });