Enum agdb::DbValue

source ·
pub enum DbValue {
    Bytes(Vec<u8>),
    I64(i64),
    U64(u64),
    F64(DbF64),
    String(String),
    VecI64(Vec<i64>),
    VecU64(Vec<u64>),
    VecF64(Vec<DbF64>),
    VecString(Vec<String>),
}
Expand description

Database value is a strongly types value.

It is an enum of limited number supported types that are universal across all platforms and programming languages.

The value is constructible from large number of raw types or associated types (e.g. i32, &str, etc.). Getting the raw value back as string can be done with to_string() but otherwise requires a match.

Variants§

§

Bytes(Vec<u8>)

Byte array, sometimes referred to as blob

§

I64(i64)

64-bit wide signed integer

§

U64(u64)

64-bit wide unsigned integer

§

F64(DbF64)

64-bit floating point number

§

String(String)

UTF-8 string

§

VecI64(Vec<i64>)

List of 64-bit wide signed integers

§

VecU64(Vec<u64>)

List of 64-bit wide unsigned integers

§

VecF64(Vec<DbF64>)

List of 64-bit floating point numbers

§

VecString(Vec<String>)

List of UTF-8 strings

Implementations§

source§

impl DbValue

source

pub fn bytes(&self) -> Result<&Vec<u8>, DbError>

Returns &Vec<u8> or an error if the value is of a different type.

source

pub fn string(&self) -> Result<&String, DbError>

Returns &String or an error if the value is of a different type.

source

pub fn to_f64(&self) -> Result<DbF64, DbError>

Returns DbF64 possibly converted from i64 or u64 or na error if the conversion failed or the value is of a different type.

source

pub fn to_i64(&self) -> Result<i64, DbError>

Returns i64 possibly converted from u64 or na error if the conversion failed or the value is of a different type.

source

pub fn to_u64(&self) -> Result<u64, DbError>

Returns u64 possibly converted from i64 or na error if the conversion failed or the value is of a different type.

source

pub fn vec_f64(&self) -> Result<&Vec<DbF64>, DbError>

Returns &Vec<DbF64> or an error if the value is of a different type.

source

pub fn vec_i64(&self) -> Result<&Vec<i64>, DbError>

Returns &Vec<i64> or an error if the value is of a different type.

source

pub fn vec_u64(&self) -> Result<&Vec<u64>, DbError>

Returns &Vec<u64> or an error if the value is of a different type.

source

pub fn vec_string(&self) -> Result<&Vec<String>, DbError>

Returns &Vec<String> or an error if the value is of a different type.

Trait Implementations§

source§

impl Clone for DbValue

source§

fn clone(&self) -> DbValue

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 DbValue

source§

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

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

impl Default for DbValue

source§

fn default() -> Self

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

impl Display for DbValue

source§

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

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

impl From<&String> for DbValue

source§

fn from(value: &String) -> Self

Converts to this type from the input type.
source§

impl From<&str> for DbValue

source§

fn from(value: &str) -> Self

Converts to this type from the input type.
source§

impl From<DbF64> for DbValue

source§

fn from(value: DbF64) -> Self

Converts to this type from the input type.
source§

impl From<String> for DbValue

source§

fn from(value: String) -> Self

Converts to this type from the input type.
source§

impl From<Vec<&str>> for DbValue

source§

fn from(value: Vec<&str>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<DbF64>> for DbValue

source§

fn from(value: Vec<DbF64>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<String>> for DbValue

source§

fn from(value: Vec<String>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<f32>> for DbValue

source§

fn from(value: Vec<f32>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<f64>> for DbValue

source§

fn from(value: Vec<f64>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<i32>> for DbValue

source§

fn from(value: Vec<i32>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<i64>> for DbValue

source§

fn from(value: Vec<i64>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<u32>> for DbValue

source§

fn from(value: Vec<u32>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<u64>> for DbValue

source§

fn from(value: Vec<u64>) -> Self

Converts to this type from the input type.
source§

impl From<Vec<u8>> for DbValue

source§

fn from(value: Vec<u8>) -> Self

Converts to this type from the input type.
source§

impl From<f32> for DbValue

source§

fn from(value: f32) -> Self

Converts to this type from the input type.
source§

impl From<f64> for DbValue

source§

fn from(value: f64) -> Self

Converts to this type from the input type.
source§

impl From<i32> for DbValue

source§

fn from(value: i32) -> Self

Converts to this type from the input type.
source§

impl From<i64> for DbValue

source§

fn from(value: i64) -> Self

Converts to this type from the input type.
source§

impl From<u32> for DbValue

source§

fn from(value: u32) -> Self

Converts to this type from the input type.
source§

impl From<u64> for DbValue

source§

fn from(value: u64) -> Self

Converts to this type from the input type.
source§

impl Hash for DbValue

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for DbValue

source§

fn cmp(&self, other: &DbValue) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for DbValue

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for DbValue

source§

fn partial_cmp(&self, other: &DbValue) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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 · source§

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
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl TryFrom<DbValue> for String

§

type Error = DbError

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

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

Performs the conversion.
source§

impl TryFrom<DbValue> for Vec<String>

§

type Error = DbError

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

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

Performs the conversion.
source§

impl TryFrom<DbValue> for Vec<f32>

§

type Error = DbError

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

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

Performs the conversion.
source§

impl TryFrom<DbValue> for Vec<f64>

§

type Error = DbError

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

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

Performs the conversion.
source§

impl TryFrom<DbValue> for Vec<i32>

§

type Error = DbError

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

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

Performs the conversion.
source§

impl TryFrom<DbValue> for Vec<i64>

§

type Error = DbError

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

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

Performs the conversion.
source§

impl TryFrom<DbValue> for Vec<u32>

§

type Error = DbError

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

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

Performs the conversion.
source§

impl TryFrom<DbValue> for Vec<u64>

§

type Error = DbError

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

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

Performs the conversion.
source§

impl TryFrom<DbValue> for Vec<u8>

§

type Error = DbError

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

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

Performs the conversion.
source§

impl TryFrom<DbValue> for f32

§

type Error = DbError

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

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

Performs the conversion.
source§

impl TryFrom<DbValue> for f64

§

type Error = DbError

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

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

Performs the conversion.
source§

impl TryFrom<DbValue> for i32

§

type Error = DbError

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

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

Performs the conversion.
source§

impl TryFrom<DbValue> for i64

§

type Error = DbError

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

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

Performs the conversion.
source§

impl TryFrom<DbValue> for u32

§

type Error = DbError

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

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

Performs the conversion.
source§

impl TryFrom<DbValue> for u64

§

type Error = DbError

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

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

Performs the conversion.
source§

impl Eq for DbValue

source§

impl StructuralPartialEq for DbValue

Auto Trait Implementations§

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> 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> ToOwned for T
where T: Clone,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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.