Enum assembly_fdb_core::value::ValueType

source ·
pub enum ValueType {
    Nothing,
    Integer,
    Float,
    Text,
    Boolean,
    BigInt,
    VarChar,
}
Expand description

Value datatypes used in the database

Variants§

§

Nothing

The NULL value

§

Integer

A 32-bit signed integer

§

Float

A 32-bit IEEE floating point number

§

Text

A long string

§

Boolean

A boolean

§

BigInt

A 64 bit integer

§

VarChar

An (XML?) string

Implementations§

source§

impl ValueType

source

pub fn static_name(&self) -> &'static str

Get a static name for the type

source

pub fn to_sqlite_type(self) -> &'static str

Get the canonical SQLite name of this data type

source

pub fn from_sqlite_type(decl_type: &str) -> Option<Self>

Take an SQLite column declaration type and guess the ValueType

This function does a proper round-trip with to_sqlite_type

use assembly_fdb_core::value::ValueType;

fn round_trip(v: ValueType) -> Option<ValueType> {
    ValueType::from_sqlite_type(v.to_sqlite_type())
}

// Check whether the round-trip works
assert_eq!(round_trip(ValueType::Nothing), Some(ValueType::Nothing));
assert_eq!(round_trip(ValueType::Integer), Some(ValueType::Integer));
assert_eq!(round_trip(ValueType::Float), Some(ValueType::Float));
assert_eq!(round_trip(ValueType::Text), Some(ValueType::Text));
assert_eq!(round_trip(ValueType::Boolean), Some(ValueType::Boolean));
assert_eq!(round_trip(ValueType::BigInt), Some(ValueType::BigInt));
assert_eq!(round_trip(ValueType::VarChar), Some(ValueType::VarChar));

// Check whether lcdr's names work
assert_eq!(ValueType::from_sqlite_type("none"), Some(ValueType::Nothing));
assert_eq!(ValueType::from_sqlite_type("int32"), Some(ValueType::Integer));
assert_eq!(ValueType::from_sqlite_type("real"), Some(ValueType::Float));
assert_eq!(ValueType::from_sqlite_type("text_4"), Some(ValueType::Text));
assert_eq!(ValueType::from_sqlite_type("int_bool"), Some(ValueType::Boolean));
assert_eq!(ValueType::from_sqlite_type("int64"), Some(ValueType::BigInt));
assert_eq!(ValueType::from_sqlite_type("text_8"), Some(ValueType::VarChar));

Trait Implementations§

source§

impl Clone for ValueType

source§

fn clone(&self) -> ValueType

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 ValueType

source§

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

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

impl Display for ValueType

source§

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

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

impl<T: Context> From<&Value<T>> for ValueType

source§

fn from(val: &Value<T>) -> Self

Converts to this type from the input type.
source§

impl From<ValueType> for u32

source§

fn from(value_type: ValueType) -> u32

Converts to this type from the input type.
source§

impl From<ValueType> for u8

source§

fn from(value_type: ValueType) -> u8

Converts to this type from the input type.
source§

impl PartialEq for ValueType

source§

fn eq(&self, other: &ValueType) -> 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 Serialize for ValueType

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl TryFrom<u32> for ValueType

§

type Error = UnknownValueType

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

fn try_from(value_type: u32) -> Result<ValueType, Self::Error>

Performs the conversion.
source§

impl Copy for ValueType

source§

impl Eq for ValueType

source§

impl StructuralPartialEq for ValueType

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

source§

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

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

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

source§

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

🔬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> 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.