SQLiteType

Enum SQLiteType 

Source
pub enum SQLiteType {
    Integer,
    Text,
    Blob,
    Real,
    Numeric,
    Any,
}
Expand description

Enum representing supported SQLite column types.

These correspond to the SQLite storage classes. Each type maps to specific Rust types and has different capabilities for constraints and features.

§Examples

use drizzle_types::sqlite::SQLiteType;

let int_type = SQLiteType::Integer;
assert_eq!(int_type.to_sql_type(), "INTEGER");
assert!(int_type.is_valid_flag("autoincrement"));

let text_type = SQLiteType::Text;
assert!(text_type.is_valid_flag("json"));
assert!(!text_type.is_valid_flag("autoincrement"));

Variants§

§

Integer

SQLite INTEGER type - stores signed integers up to 8 bytes.

See: https://sqlite.org/datatype3.html#integer_datatype

Supports: primary keys, autoincrement, enums (discriminant storage)

§

Text

SQLite TEXT type - stores text in UTF-8, UTF-16BE, or UTF-16LE encoding.

See: https://sqlite.org/datatype3.html#text_datatype

Supports: enums (variant name storage), JSON serialization

§

Blob

SQLite BLOB type - stores binary data exactly as input.

See: https://sqlite.org/datatype3.html#blob_datatype

Supports: JSON serialization, UUID storage

§

Real

SQLite REAL type - stores floating point values as 8-byte IEEE floating point numbers.

See: https://sqlite.org/datatype3.html#real_datatype

§

Numeric

SQLite NUMERIC type - stores values as INTEGER, REAL, or TEXT depending on the value.

See: https://sqlite.org/datatype3.html#numeric_datatype

§

Any

SQLite ANY type - no type affinity, can store any type of data.

See: https://sqlite.org/datatype3.html#type_affinity

Implementations§

Source§

impl SQLiteType

Source

pub fn from_attribute_name(name: &str) -> Option<Self>

Convert from attribute name to enum variant

Handles common attribute names used in the macro system.

Source

pub const fn to_sql_type(&self) -> &'static str

Get the SQL type string for this type

Source

pub fn is_valid_flag(&self, flag: &str) -> bool

Check if a flag is valid for this column type

§Valid Flags per Type
  • INTEGER: primary, primary_key, unique, autoincrement, enum
  • TEXT: primary, primary_key, unique, json, enum
  • BLOB: primary, primary_key, unique, json
  • REAL: primary, primary_key, unique
  • NUMERIC: primary, primary_key, unique
  • ANY: primary, primary_key, unique

Trait Implementations§

Source§

impl Clone for SQLiteType

Source§

fn clone(&self) -> SQLiteType

Returns a duplicate 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 SQLiteType

Source§

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

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

impl Default for SQLiteType

Source§

fn default() -> SQLiteType

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

impl Display for SQLiteType

Source§

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

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

impl Hash for SQLiteType

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 PartialEq for SQLiteType

Source§

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

Source§

impl Eq for SQLiteType

Source§

impl StructuralPartialEq for SQLiteType

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§

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

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

Source§

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

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.