Skip to main content

DocumentExt

Trait DocumentExt 

Source
pub trait DocumentExt {
Show 16 methods // Required methods fn get_str(&self, key: &str) -> MongoResult<&str>; fn get_str_opt(&self, key: &str) -> Option<&str>; fn get_i32(&self, key: &str) -> MongoResult<i32>; fn get_i32_opt(&self, key: &str) -> Option<i32>; fn get_i64(&self, key: &str) -> MongoResult<i64>; fn get_i64_opt(&self, key: &str) -> Option<i64>; fn get_bool(&self, key: &str) -> MongoResult<bool>; fn get_bool_opt(&self, key: &str) -> Option<bool>; fn get_object_id(&self, key: &str) -> MongoResult<ObjectId>; fn get_object_id_opt(&self, key: &str) -> Option<ObjectId>; fn get_document(&self, key: &str) -> MongoResult<&Document>; fn get_document_opt(&self, key: &str) -> Option<&Document>; fn get_array(&self, key: &str) -> MongoResult<&Vec<Bson>>; fn get_array_opt(&self, key: &str) -> Option<&Vec<Bson>>; fn to_struct<T: DeserializeOwned>(&self) -> MongoResult<T>; fn id(&self) -> MongoResult<ObjectId>;
}
Expand description

Extension trait for BSON documents.

Required Methods§

Source

fn get_str(&self, key: &str) -> MongoResult<&str>

Get a string value from the document.

Source

fn get_str_opt(&self, key: &str) -> Option<&str>

Get an optional string value.

Source

fn get_i32(&self, key: &str) -> MongoResult<i32>

Get an i32 value.

Source

fn get_i32_opt(&self, key: &str) -> Option<i32>

Get an optional i32 value.

Source

fn get_i64(&self, key: &str) -> MongoResult<i64>

Get an i64 value.

Source

fn get_i64_opt(&self, key: &str) -> Option<i64>

Get an optional i64 value.

Source

fn get_bool(&self, key: &str) -> MongoResult<bool>

Get a bool value.

Source

fn get_bool_opt(&self, key: &str) -> Option<bool>

Get an optional bool value.

Source

fn get_object_id(&self, key: &str) -> MongoResult<ObjectId>

Get an ObjectId value.

Source

fn get_object_id_opt(&self, key: &str) -> Option<ObjectId>

Get an optional ObjectId value.

Source

fn get_document(&self, key: &str) -> MongoResult<&Document>

Get a nested document.

Source

fn get_document_opt(&self, key: &str) -> Option<&Document>

Get an optional nested document.

Source

fn get_array(&self, key: &str) -> MongoResult<&Vec<Bson>>

Get an array value.

Source

fn get_array_opt(&self, key: &str) -> Option<&Vec<Bson>>

Get an optional array value.

Source

fn to_struct<T: DeserializeOwned>(&self) -> MongoResult<T>

Convert to a typed struct.

Source

fn id(&self) -> MongoResult<ObjectId>

Get the _id field as ObjectId.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§