Enum Value

Source
#[non_exhaustive]
pub enum Value {
Show 26 variants Void, Null, Bool(bool), Int8(i8), Uint8(u8), Int16(i16), Uint16(u16), Int32(i32), Uint32(u32), Int64(i64), Uint64(u64), Float(f32), Double(f64), Date(SystemTime), DateTime(SystemTime), Timestamp(SystemTime), Interval(SignedInterval), Bytes(Bytes), Text(String), Yson(Bytes), Json(String), JsonDocument(String), Optional(Box<ValueOptional>), List(Box<ValueList>), Struct(ValueStruct), Decimal(Decimal),
}
Expand description

Internal represent database value for send to or received from database.

That enum will be grow, when add support of new types

§Convert from Value to native types

§Primitive values

§From Value to native types

Convert from Value to primitive rust types do by TryFrom trait Try need because Value can contain any DB value and it can’ check at compile time.


// Simple convert to native type
let v: i16 = Value::Int16(123).try_into()?;
assert_eq!(123 as i16, v);

// Simple types can be extended while convert to native type
let v: i32 = Value::Int16(123).try_into()?;
assert_eq!(123 as i32, v);
§From native type to Value
// while convert to Value - value internal type exact same as source type - without auto-extended
// because real target type doesn't known in compile time
let v: Value = (123 as i16).into();
assert_eq!(Value::Int16(123), v);
§Possible native convertions

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Void

§

Null

§

Bool(bool)

§

Int8(i8)

§

Uint8(u8)

§

Int16(i16)

§

Uint16(u16)

§

Int32(i32)

§

Uint32(u32)

§

Int64(i64)

§

Uint64(u64)

§

Float(f32)

§

Double(f64)

§

Date(SystemTime)

§

DateTime(SystemTime)

§

Timestamp(SystemTime)

§

Interval(SignedInterval)

§

Bytes(Bytes)

§

Text(String)

Text data, encoded to valid utf8

§

Yson(Bytes)

§

Json(String)

§

JsonDocument(String)

§

Optional(Box<ValueOptional>)

§

List(Box<ValueList>)

§

Struct(ValueStruct)

§

Decimal(Decimal)

Implementations§

Source§

impl Value

Source

pub fn list_from(example_value: Value, values: Vec<Value>) -> YdbResult<Self>

list_from create Value from example of item and values example value must be same type as items in value it used for describe type in query.

It can’t use one of values because values can be empty. Example:

 let v = Value::list_from(0.into(), vec![1.into(), 2.into(), 3.into()])?;
}
Source

pub fn struct_from_fields(fields: Vec<(String, Value)>) -> Value

Create struct value from fields in form name, value.

Example:

let v = Value::struct_from_fields(vec![
    ("id".to_string(), 1.into()),
    ("value".to_string(), "test-value".into()),
]);
Source

pub fn is_optional(&self) -> bool

Return true if the Value is optional

Source

pub fn to_option(self) -> Option<Value>

present current value as Option if value is Optional - return inner unwrapper value. else - return self, wrapped to Option.

Trait Implementations§

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 EnumCount for Value

Source§

const COUNT: usize = 26usize

Source§

impl From<&str> for Value

Source§

fn from(v: &str) -> Self

Converts to this type from the input type.
Source§

impl From<Bytes> for Value

Source§

fn from(value: Bytes) -> Self

Converts to this type from the input type.
Source§

impl From<Decimal> for Value

Source§

fn from(value: Decimal) -> Self

Converts to this type from the input type.
Source§

impl From<HashMap<String, Value>> for Value

Source§

fn from(from_val: HashMap<String, Value>) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<Value> + Default> From<Option<T>> for Value

Source§

fn from(from_value: Option<T>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl From<SystemTime> for Value

Source§

fn from(value: SystemTime) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Value

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Value

Source§

fn from(value: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Value

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for Value

Source§

fn from(value: i8) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Value

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Value

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Value

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Value

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<Value> + Default> FromIterator<T> for Value

Source§

fn from_iter<T2: IntoIterator<Item = T>>(iter: T2) -> Self

Creates a value from an iterator. 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 TryFrom<Value> for Bytes

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Decimal

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for HashMap<String, Value>

Source§

type Error = YdbError

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

fn try_from(from_value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Option<Bytes>

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Option<Decimal>

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Option<String>

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Option<SystemTime>

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Option<bool>

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Option<f32>

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Option<f64>

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Option<i16>

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Option<i32>

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Option<i64>

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Option<i8>

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Option<u16>

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Option<u32>

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Option<u64>

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Option<u8>

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for String

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for SystemTime

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<T> TryFrom<Value> for Vec<T>
where T: TryFrom<Value, Error = YdbError>,

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for bool

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for f32

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for f64

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for i16

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for i32

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for i64

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for i8

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for u16

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for u32

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for u64

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for u8

Source§

type Error = YdbError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
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> Any for T
where T: Any + ?Sized,

Source§

fn type_id_compat(&self) -> TypeId

TODO: once 1.33.0 is the minimum supported compiler version, remove Any::type_id_compat and use StdAny::type_id instead. https://github.com/rust-lang/rust/issues/27745
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, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,