pub enum Value {
Null,
Bool(bool),
U64(u64),
I64(i64),
F64(f64),
Str(String),
Bytes(Vec<u8>),
Timestamp(i64),
Internal(i64),
}
Expand description
Value
Value is MultiSQL’s value wrapper and stores any values which interact with the stores. At times they may be converted in the interface for convinence but otherwise, all value interactions with MultiSQL require this wrapper.
Conversion
Value implements conversion from inner types; for example:
let value: Value = Value::I64(10);
let int: i64 = 10;
let int_value: Value = int.into();
assert_eq!(value, int_value);
Casting
Values can be cast between types via Cast, for example:
let value_str: Value = Value::Str(String::from("10"));
let int: i64 = 10;
let str_int: i64 = value_str.cast().unwrap();
assert_eq!(int, str_int);
assert_eq!(Value::I64(int), Value::I64(Value::Str(String::from("10")).cast().unwrap()));
Equality
Values of the same type compare as their inner values would.
Null never equals Null.
Floats and Integers implicitly compare and convert.
(Feature: implicit_float_conversion
)
Variants
Null
Bool(bool)
U64(u64)
I64(i64)
F64(f64)
Str(String)
Bytes(Vec<u8>)
Timestamp(i64)
Internal(i64)
Implementations
sourceimpl Value
impl Value
pub fn aggregate_count(self, other: Value) -> Result<Value>
pub fn aggregate_min(self, other: Value) -> Result<Value>
pub fn aggregate_max(self, other: Value) -> Result<Value>
pub fn aggregate_sum(self, other: Value) -> Result<Value>
sourceimpl Value
impl Value
pub fn add<Core>(self, other: Self) -> Result<Self> where
Core: ValueCore + Add<Output = Core>,
pub fn generic_add(self, other: Self) -> Result<Self>
pub fn subtract<Core>(self, other: Self) -> Result<Self> where
Core: ValueCore + Sub<Output = Core>,
pub fn generic_subtract(self, other: Self) -> Result<Self>
pub fn multiply<Core>(self, other: Self) -> Result<Self> where
Core: ValueCore + Mul<Output = Core>,
pub fn generic_multiply(self, other: Self) -> Result<Self>
pub fn divide<Core>(self, other: Self) -> Result<Self> where
Core: ValueCore + Div<Output = Core>,
pub fn generic_divide(self, other: Self) -> Result<Self>
pub fn modulus<Core>(self, other: Self) -> Result<Self> where
Core: ValueCore + Rem<Output = Core>,
pub fn generic_modulus(self, other: Self) -> Result<Self>
sourceimpl Value
impl Value
pub fn eq(self, other: Self) -> Result<Self>
pub fn not_eq(self, other: Self) -> Result<Self>
pub fn gt(self, other: Self) -> Result<Self>
pub fn gt_eq(self, other: Self) -> Result<Self>
pub fn lt(self, other: Self) -> Result<Self>
pub fn lt_eq(self, other: Self) -> Result<Self>
sourceimpl Value
impl Value
pub fn string_concat(self, other: Self) -> Result<Self>
sourceimpl Value
impl Value
pub fn function_if_null(arguments: Vec<Self>) -> Result<Self>
pub fn function_null_if(arguments: Vec<Self>) -> Result<Self>
pub fn function_iif(arguments: Vec<Self>) -> Result<Self>
pub fn function_to_lowercase(arguments: Vec<Self>) -> Result<Self>
pub fn function_to_uppercase(arguments: Vec<Self>) -> Result<Self>
pub fn function_left(arguments: Vec<Self>) -> Result<Self>
pub fn function_right(arguments: Vec<Self>) -> Result<Self>
pub fn function_length(arguments: Vec<Self>) -> Result<Self>
pub fn function_concat(arguments: Vec<Self>) -> Result<Self>
pub fn function_replace(arguments: Vec<Self>) -> Result<Self>
pub fn function_round(arguments: Vec<Self>) -> Result<Self>
pub fn function_rand(arguments: Vec<Self>) -> Result<Self>
pub fn function_random_float(arguments: Vec<Self>) -> Result<Self>
pub fn function_random_int(arguments: Vec<Self>) -> Result<Self>
pub fn function_uuid(arguments: Vec<Self>) -> Result<Self>
pub fn function_pow(arguments: Vec<Self>) -> Result<Self>
pub fn function_convert(arguments: Vec<Self>) -> Result<Self>
pub fn function_try_convert(arguments: Vec<Self>) -> Result<Self>
sourceimpl Value
impl Value
pub fn function_now(arguments: Vec<Self>) -> Result<Self>
pub fn function_year(arguments: Vec<Self>) -> Result<Self>
pub fn function_month(arguments: Vec<Self>) -> Result<Self>
pub fn function_day(arguments: Vec<Self>) -> Result<Self>
pub fn function_hour(arguments: Vec<Self>) -> Result<Self>
pub fn function_minute(arguments: Vec<Self>) -> Result<Self>
pub fn function_second(arguments: Vec<Self>) -> Result<Self>
pub fn function_timestamp_add(arguments: Vec<Self>) -> Result<Self>
pub fn function_timestamp_from_parts(arguments: Vec<Self>) -> Result<Self>
sourceimpl Value
impl Value
pub fn unary_plus<Core>(self) -> Result<Self> where
Core: ValueCore + Clone,
pub fn unary_minus<Core>(self) -> Result<Self> where
Core: ValueCore + Neg<Output = Core>,
pub fn generic_unary_plus(self) -> Result<Self>
pub fn generic_unary_minus(self) -> Result<Self>
pub fn not(self) -> Result<Self>
pub fn is_null(self) -> Result<Self>
sourceimpl Value
impl Value
pub fn if_null(self, alternative: Self) -> Self
pub fn null_if(self, evaluate: Self) -> Result<Self>
pub fn iif(self, case_true: Self, case_false: Self) -> Result<Self>
pub fn to_uppercase(self) -> Result<Self>
pub fn to_lowercase(self) -> Result<Self>
pub fn left(self, length: Value) -> Result<Value>
pub fn right(self, length: Value) -> Result<Value>
pub fn length(self) -> Result<Value>
pub fn concat(self, strings: Vec<Value>) -> Result<Value>
pub fn replace(self, from: Value, to: Value) -> Result<Value>
pub fn round(self, places: Value) -> Result<Value>
pub fn pow(self, power: Value) -> Result<Value>
sourceimpl Value
impl Value
pub fn validate_type(self, data_type: &DataType) -> Result<Self>
pub fn is(&mut self, data_type: &ValueType) -> Result<()>
pub fn validate_null(&self, nullable: bool) -> Result<()>
pub fn cast_datatype(&self, data_type: &DataType) -> Result<Self>
pub fn inc(&self) -> Self
pub fn dec(&self) -> Self
Trait Implementations
sourceimpl Cast<NaiveDateTime> for Value
impl Cast<NaiveDateTime> for Value
fn cast(self) -> Result<NaiveDateTime>
sourceimpl CastWithRules<NaiveDateTime> for Value
impl CastWithRules<NaiveDateTime> for Value
fn cast_with_rule(self, rule: Self) -> Result<NaiveDateTime>
sourceimpl CastWithRules<String> for Value
impl CastWithRules<String> for Value
fn cast_with_rule(self, rule: Self) -> Result<String>
sourceimpl CastWithRules<bool> for Value
impl CastWithRules<bool> for Value
fn cast_with_rule(self, rule: Self) -> Result<bool>
sourceimpl CastWithRules<f64> for Value
impl CastWithRules<f64> for Value
fn cast_with_rule(self, rule: Self) -> Result<f64>
sourceimpl CastWithRules<i64> for Value
impl CastWithRules<i64> for Value
fn cast_with_rule(self, rule: Self) -> Result<i64>
sourceimpl Convert<NaiveDateTime> for Value
impl Convert<NaiveDateTime> for Value
fn convert(self) -> Result<NaiveDateTime>
sourceimpl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Ord for Value
impl Ord for Value
sourceimpl PartialOrd<Value> for Value
impl PartialOrd<Value> for Value
sourcefn partial_cmp(&self, other: &Value) -> Option<Ordering>
fn partial_cmp(&self, other: &Value) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for Value
Auto Trait Implementations
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more