Enum assembly_fdb::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
impl ValueType
sourcepub fn static_name(&self) -> &'static str
pub fn static_name(&self) -> &'static str
Get a static name for the type
sourcepub fn to_sqlite_type(self) -> &'static str
pub fn to_sqlite_type(self) -> &'static str
Get the canonical SQLite name of this data type
sourcepub fn from_sqlite_type(decl_type: &str) -> Option<ValueType>
pub fn from_sqlite_type(decl_type: &str) -> Option<ValueType>
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 PartialEq<ValueType> for ValueType
impl PartialEq<ValueType> for ValueType
source§impl Serialize for ValueType
impl Serialize for ValueType
source§fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where __S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for ValueType
impl Eq for ValueType
impl StructuralEq for ValueType
impl StructuralPartialEq for ValueType
Auto Trait Implementations§
impl RefUnwindSafe for ValueType
impl Send for ValueType
impl Sync for ValueType
impl Unpin for ValueType
impl UnwindSafe for ValueType
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more