Enum Value

Source
pub enum Value {
Show 15 variants MinValue, Null, Int32(i32), Int64(i64), Double(f64), Decimal(Decimal128), String(String), Document(Document), Array(Array), Binary(Binary), ObjectId(ObjectId), Guid(Guid), Boolean(bool), DateTime(DateTime), MaxValue,
}
Expand description

The num represents one bson value.

Any instance of this value can be expressed in this enum can be serialized to binary representation without any error

Variants§

§

MinValue

The MinValue. The smallest value of bson value

§

Null

The null value.

§

Int32(i32)

The signed 32bit integer.

§

Int64(i64)

The signed 64bit integer.

§

Double(f64)

The IEEE 754 binary64 floating point value.

§

Decimal(Decimal128)

The IEEE 754 decimal128 floating point value.

§

String(String)

The UTF-8 encoded string value

§

Document(Document)

The string key mapping

§

Array(Array)

The array of bson value

§

Binary(Binary)

The byte array

§

ObjectId(ObjectId)

ObjectId

§

Guid(Guid)

Guid In bson representation this will be expressed as UUID binary

§

Boolean(bool)

Boolean

§

DateTime(DateTime)

DateTime Time can be represented with this is 0001-01-01 to 9999-12-31 since date time in C# is so

§

MaxValue

The MaxValue. The biggest value of bson value

Implementations§

Source§

impl Value

Source

pub fn ty(&self) -> BsonType

Source§

impl Value

Source

pub fn get_serialized_value_len(&self) -> usize

Returns the size of serialized value.

This doesn’t include tag or name of key.

Source

pub fn write_value<W: BsonWriter>(&self, w: &mut W) -> Result<(), W::Error>

Writes the value to the BsonWriter

Source§

impl Value

Source

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

Source

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

Source

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

Source

pub fn as_decimal128(&self) -> Option<Decimal128>

Source

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

Source

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

Source

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

Source

pub fn into_document(self) -> Result<Document, Self>

Source

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

Source

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

Source

pub fn into_array(self) -> Result<Array, Self>

Source

pub fn as_binary(&self) -> Option<&Binary>

Source

pub fn as_binary_mut(&mut self) -> Option<&mut Binary>

Source

pub fn into_binary(self) -> Result<Binary, Self>

Source

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

Source

pub fn as_guid(&self) -> Option<Guid>

Source

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

Source

pub fn as_date_time(&self) -> Option<DateTime>

Source

pub fn is_number(&self) -> bool

Source

pub fn to_i32(&self) -> Option<i32>

Source

pub fn to_i64(&self) -> Option<i64>

Source

pub fn to_f64(&self) -> Option<f64>

Source

pub fn to_decimal(&self) -> Option<Decimal128>

Trait Implementations§

Source§

impl Add for &Value

Source§

type Output = Value

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Div for &Value

Source§

type Output = Value

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl From<&[Value]> for Value

Source§

fn from(v: &[Value]) -> Value

Converts to this type from the input type.
Source§

impl From<&String> for Value

Source§

fn from(v: &String) -> Value

Converts to this type from the input type.
Source§

impl From<&Vec<Value>> for Value

Source§

fn from(v: &Vec<Value>) -> Value

Converts to this type from the input type.
Source§

impl From<&str> for Value

Source§

fn from(v: &str) -> Value

Converts to this type from the input type.
Source§

impl<const L: usize> From<[Value; L]> for Value

Source§

fn from(v: [Value; L]) -> Value

Converts to this type from the input type.
Source§

impl From<Array> for Value

Source§

fn from(v: Array) -> Value

Converts to this type from the input type.
Source§

impl From<Binary> for Value

Source§

fn from(v: Binary) -> Value

Converts to this type from the input type.
Source§

impl From<DateTime> for Value

Source§

fn from(v: DateTime) -> Value

Converts to this type from the input type.
Source§

impl From<Decimal128> for Value

Source§

fn from(v: Decimal128) -> Value

Converts to this type from the input type.
Source§

impl From<Document> for Value

Source§

fn from(v: Document) -> Value

Converts to this type from the input type.
Source§

impl From<Guid> for Value

Source§

fn from(v: Guid) -> Value

Converts to this type from the input type.
Source§

impl From<ObjectId> for Value

Source§

fn from(v: ObjectId) -> Value

Converts to this type from the input type.
Source§

impl<T> From<Option<T>> for Value
where Value: From<T>,

Source§

fn from(value: Option<T>) -> Value

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(v: String) -> Value

Converts to this type from the input type.
Source§

impl From<Vec<Value>> for Value

Source§

fn from(v: Vec<Value>) -> Value

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(v: bool) -> Value

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(v: f64) -> Value

Converts to this type from the input type.
Source§

impl From<i32> for Value

Source§

fn from(v: i32) -> Value

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(v: i64) -> Value

Converts to this type from the input type.
Source§

impl Mul for &Value

Source§

type Output = Value

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Value) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Sub for &Value

Source§

type Output = Value

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl TotalOrd for Value

Source§

fn total_cmp(&self, other: &Self) -> Ordering

Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnwindSafe for Value

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V