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§
Sourcefn get_str(&self, key: &str) -> MongoResult<&str>
fn get_str(&self, key: &str) -> MongoResult<&str>
Get a string value from the document.
Sourcefn get_str_opt(&self, key: &str) -> Option<&str>
fn get_str_opt(&self, key: &str) -> Option<&str>
Get an optional string value.
Sourcefn get_i32(&self, key: &str) -> MongoResult<i32>
fn get_i32(&self, key: &str) -> MongoResult<i32>
Get an i32 value.
Sourcefn get_i32_opt(&self, key: &str) -> Option<i32>
fn get_i32_opt(&self, key: &str) -> Option<i32>
Get an optional i32 value.
Sourcefn get_i64(&self, key: &str) -> MongoResult<i64>
fn get_i64(&self, key: &str) -> MongoResult<i64>
Get an i64 value.
Sourcefn get_i64_opt(&self, key: &str) -> Option<i64>
fn get_i64_opt(&self, key: &str) -> Option<i64>
Get an optional i64 value.
Sourcefn get_bool(&self, key: &str) -> MongoResult<bool>
fn get_bool(&self, key: &str) -> MongoResult<bool>
Get a bool value.
Sourcefn get_bool_opt(&self, key: &str) -> Option<bool>
fn get_bool_opt(&self, key: &str) -> Option<bool>
Get an optional bool value.
Sourcefn get_object_id(&self, key: &str) -> MongoResult<ObjectId>
fn get_object_id(&self, key: &str) -> MongoResult<ObjectId>
Get an ObjectId value.
Sourcefn get_object_id_opt(&self, key: &str) -> Option<ObjectId>
fn get_object_id_opt(&self, key: &str) -> Option<ObjectId>
Get an optional ObjectId value.
Sourcefn get_document(&self, key: &str) -> MongoResult<&Document>
fn get_document(&self, key: &str) -> MongoResult<&Document>
Get a nested document.
Sourcefn get_document_opt(&self, key: &str) -> Option<&Document>
fn get_document_opt(&self, key: &str) -> Option<&Document>
Get an optional nested document.
Sourcefn to_struct<T: DeserializeOwned>(&self) -> MongoResult<T>
fn to_struct<T: DeserializeOwned>(&self) -> MongoResult<T>
Convert to a typed struct.
Sourcefn id(&self) -> MongoResult<ObjectId>
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.