Enum bson::Bson[][src]

pub enum Bson {
Show variants Double(f64), String(String), Array(Array), Document(Document), Boolean(bool), Null, RegularExpression(Regex), JavaScriptCode(String), JavaScriptCodeWithScope(JavaScriptCodeWithScope), Int32(i32), Int64(i64), Timestamp(Timestamp), Binary(Binary), ObjectId(ObjectId), DateTime(DateTime), Symbol(String), Decimal128(Decimal128), Undefined, MaxKey, MinKey, DbPointer(DbPointer),
}
Expand description

Possible BSON value types.

Variants

Double(f64)
Expand description

64-bit binary floating point

String(String)
Expand description

UTF-8 string

Array(Array)
Expand description

Array

Document(Document)
Expand description

Embedded document

Boolean(bool)
Expand description

Boolean value

Null
Expand description

Null value

RegularExpression(Regex)
Expand description

Regular expression

JavaScriptCode(String)
Expand description

JavaScript code

JavaScriptCodeWithScope(JavaScriptCodeWithScope)
Expand description

JavaScript code w/ scope

Int32(i32)
Expand description

32-bit signed integer

Int64(i64)
Expand description

64-bit signed integer

Timestamp(Timestamp)
Expand description

Timestamp

Binary(Binary)
Expand description

Binary data

ObjectId(ObjectId)
Expand description
DateTime(DateTime)
Expand description

UTC datetime

Symbol(String)
Expand description

Symbol (Deprecated)

Decimal128(Decimal128)
Expand description
Undefined
Expand description

Undefined value (Deprecated)

MaxKey
Expand description

Max key

MinKey
Expand description

Min key

DbPointer(DbPointer)
Expand description

DBPointer (Deprecated)

Implementations

impl Bson[src]

pub fn into_relaxed_extjson(self) -> Value[src]

Converts the Bson value into its relaxed extended JSON representation.

Note: extended json encoding for Decimal128 values is not supported without the “decimal128” feature flag. If this method is called on a case which contains a Decimal128 value, it will panic.

pub fn into_canonical_extjson(self) -> Value[src]

Converts the Bson value into its canonical extended JSON representation.

Note: extended json encoding for Decimal128 values is not supported without the “decimal128” feature flag. If this method is called on a case which contains a Decimal128 value, it will panic.

pub fn element_type(&self) -> ElementType[src]

Get the ElementType of this value.

impl Bson[src]

Value helpers

pub fn as_f64(&self) -> Option<f64>[src]

If Bson is Double, return its value as an f64. Returns None otherwise

pub fn as_str(&self) -> Option<&str>[src]

If Bson is String, return its value as a &str. Returns None otherwise

pub fn as_str_mut(&mut self) -> Option<&mut str>[src]

If Bson is String, return a mutable reference to its value as a str. Returns None otherwise

pub fn as_array(&self) -> Option<&Array>[src]

If Bson is Array, return its value. Returns None otherwise

pub fn as_array_mut(&mut self) -> Option<&mut Array>[src]

If Bson is Array, return a mutable reference to its value. Returns None otherwise

pub fn as_document(&self) -> Option<&Document>[src]

If Bson is Document, return its value. Returns None otherwise

pub fn as_document_mut(&mut self) -> Option<&mut Document>[src]

If Bson is Document, return a mutable reference to its value. Returns None otherwise

pub fn as_bool(&self) -> Option<bool>[src]

If Bson is Bool, return its value. Returns None otherwise

pub fn as_i32(&self) -> Option<i32>[src]

If Bson is I32, return its value. Returns None otherwise

pub fn as_i64(&self) -> Option<i64>[src]

If Bson is I64, return its value. Returns None otherwise

pub fn as_object_id(&self) -> Option<ObjectId>[src]

If Bson is Objectid, return its value. Returns None otherwise

pub fn as_object_id_mut(&mut self) -> Option<&mut ObjectId>[src]

If Bson is Objectid, return a mutable reference to its value. Returns None otherwise

pub fn as_datetime(&self) -> Option<&DateTime>[src]

If Bson is DateTime, return its value. Returns None otherwise

pub fn as_datetime_mut(&mut self) -> Option<&mut DateTime>[src]

If Bson is DateTime, return a mutable reference to its value. Returns None otherwise

pub fn as_symbol(&self) -> Option<&str>[src]

If Bson is Symbol, return its value. Returns None otherwise

pub fn as_symbol_mut(&mut self) -> Option<&mut str>[src]

If Bson is Symbol, return a mutable reference to its value. Returns None otherwise

pub fn as_timestamp(&self) -> Option<Timestamp>[src]

If Bson is Timestamp, return its value. Returns None otherwise

pub fn as_null(&self) -> Option<()>[src]

If Bson is Null, return its value. Returns None otherwise

pub fn as_db_pointer(&self) -> Option<&DbPointer>[src]

Trait Implementations

impl Clone for Bson[src]

fn clone(&self) -> Bson[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Bson[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Default for Bson[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

impl<'de> Deserialize<'de> for Bson[src]

fn deserialize<D>(deserializer: D) -> Result<Bson, D::Error> where
    D: Deserializer<'de>, 
[src]

Deserialize this value from the given Serde deserializer. Read more

impl Display for Bson[src]

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<T> From<&'_ [T]> for Bson where
    T: Clone + Into<Bson>, 
[src]

fn from(s: &[T]) -> Bson[src]

Performs the conversion.

impl<T> From<&'_ T> for Bson where
    T: Clone + Into<Bson>, 
[src]

fn from(t: &T) -> Bson[src]

Performs the conversion.

impl From<&'_ str> for Bson[src]

fn from(s: &str) -> Bson[src]

Performs the conversion.

impl From<[u8; 12]> for Bson[src]

fn from(a: [u8; 12]) -> Bson[src]

Performs the conversion.

impl From<Binary> for Bson[src]

fn from(binary: Binary) -> Bson[src]

Performs the conversion.

impl From<DateTime<Utc>> for Bson[src]

fn from(a: DateTime<Utc>) -> Bson[src]

Performs the conversion.

impl From<DbPointer> for Bson[src]

fn from(a: DbPointer) -> Bson[src]

Performs the conversion.

impl From<Document> for Bson[src]

fn from(a: Document) -> Bson[src]

Performs the conversion.

impl From<JavaScriptCodeWithScope> for Bson[src]

fn from(code_with_scope: JavaScriptCodeWithScope) -> Bson[src]

Performs the conversion.

impl From<ObjectId> for Bson[src]

fn from(a: ObjectId) -> Bson[src]

Performs the conversion.

impl From<Regex> for Bson[src]

fn from(regex: Regex) -> Bson[src]

Performs the conversion.

impl From<String> for Bson[src]

fn from(a: String) -> Bson[src]

Performs the conversion.

impl From<Timestamp> for Bson[src]

fn from(ts: Timestamp) -> Bson[src]

Performs the conversion.

impl<T> From<Vec<T, Global>> for Bson where
    T: Into<Bson>, 
[src]

fn from(v: Vec<T>) -> Bson[src]

Performs the conversion.

impl From<bool> for Bson[src]

fn from(a: bool) -> Bson[src]

Performs the conversion.

impl From<f32> for Bson[src]

fn from(a: f32) -> Bson[src]

Performs the conversion.

impl From<f64> for Bson[src]

fn from(a: f64) -> Bson[src]

Performs the conversion.

impl From<i32> for Bson[src]

fn from(a: i32) -> Bson[src]

Performs the conversion.

impl From<i64> for Bson[src]

fn from(a: i64) -> Bson[src]

Performs the conversion.

impl From<u32> for Bson[src]

fn from(a: u32) -> Bson[src]

Performs the conversion.

impl From<u64> for Bson[src]

fn from(a: u64) -> Bson[src]

Performs the conversion.

impl<T: Into<Bson>> FromIterator<T> for Bson[src]

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self[src]

Examples

use std::iter::FromIterator;
use bson::Bson;

let x: Bson = Bson::from_iter(vec!["lorem", "ipsum", "dolor"]);
// or
let x: Bson = vec!["lorem", "ipsum", "dolor"].into_iter().collect();

impl PartialEq<Bson> for Bson[src]

fn eq(&self, other: &Bson) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Bson) -> bool[src]

This method tests for !=.

impl Serialize for Bson[src]

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where
    S: Serializer
[src]

Serialize this value into the given Serde serializer. Read more

impl TryFrom<Map<String, Value>> for Bson[src]

This converts from the input JSON object as if it were MongoDB Extended JSON v2.

type Error = Error

The type returned in the event of a conversion error.

fn try_from(obj: Map<String, Value>) -> Result<Self>[src]

Performs the conversion.

impl TryFrom<Value> for Bson[src]

This converts from the input JSON as if it were MongoDB Extended JSON v2.

type Error = Error

The type returned in the event of a conversion error.

fn try_from(value: Value) -> Result<Self>[src]

Performs the conversion.

impl StructuralPartialEq for Bson[src]

Auto Trait Implementations

impl RefUnwindSafe for Bson

impl Send for Bson

impl Sync for Bson

impl Unpin for Bson

impl UnwindSafe for Bson

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T> ToString for T where
    T: Display + ?Sized
[src]

pub default fn to_string(&self) -> String[src]

Converts the given value to a String. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]