#[non_exhaustive]pub struct ValueType { /* private fields */ }Expand description
The type of a value.
This type exists in contrast to Type, which is a compile-time trait
defining a particular value type.
See Statement::column_type and Value::column_type.
§Examples
use sqll::{Connection, ValueType};
let mut c = Connection::open_in_memory()?;
c.execute(r#"
CREATE TABLE test (value INTEGER, text_value TEXT);
INSERT INTO test (value, text_value) VALUES (42, 'Hello, world!');
"#)?;
let mut select = c.prepare("SELECT value, text_value FROM test")?;
assert!(select.step()?.is_row());
assert_eq!(select.column_type(0), ValueType::INTEGER);
assert_eq!(select.column_type(1), ValueType::TEXT);Implementations§
Source§impl ValueType
impl ValueType
Sourcepub const INTEGER: Self
pub const INTEGER: Self
The integer type.
This is represented in rust by the i64 value and corresponds to the
Integer compile-time type.
§Examples
use sqll::{Connection, ValueType};
let mut c = Connection::open_in_memory()?;
c.execute(r#"
CREATE TABLE test (value INTEGER);
INSERT INTO test (value) VALUES (42);
"#)?;
let mut select = c.prepare("SELECT value FROM test")?;
assert_eq!(select.column_type(0), ValueType::NULL);
assert!(select.step()?.is_row());
assert_eq!(select.column_type(0), ValueType::INTEGER);
assert!(select.step()?.is_done());Sourcepub const FLOAT: Self
pub const FLOAT: Self
The floating-point type.
This is represented in rust by the f64 value and corresponds to the
Float compile-time type.
§Examples
use sqll::{Connection, ValueType};
let mut c = Connection::open_in_memory()?;
c.execute(r#"
CREATE TABLE test (value FLOAT);
INSERT INTO test (value) VALUES (42.0);
"#)?;
let mut select = c.prepare("SELECT value FROM test")?;
assert_eq!(select.column_type(0), ValueType::NULL);
assert!(select.step()?.is_row());
assert_eq!(select.column_type(0), ValueType::FLOAT);
assert!(select.step()?.is_done());Sourcepub const TEXT: Self
pub const TEXT: Self
The text type.
This is represented in rust by the Text value and corresponds to the
Text compile-time type.
§Examples
use sqll::{Connection, ValueType};
let mut c = Connection::open_in_memory()?;
c.execute(r#"
CREATE TABLE test (value TEXT);
INSERT INTO test (value) VALUES ('Hello, world!');
"#)?;
let mut select = c.prepare("SELECT value FROM test")?;
assert_eq!(select.column_type(0), ValueType::NULL);
assert!(select.step()?.is_row());
assert_eq!(select.column_type(0), ValueType::TEXT);
assert!(select.step()?.is_done());Sourcepub const BLOB: Self
pub const BLOB: Self
The blob type.
This is represented in rust by the [u8] slice and corresponds to the
Blob compile-time type.
§Examples
use sqll::{Connection, ValueType};
let mut c = Connection::open_in_memory()?;
c.execute(r#"
CREATE TABLE test (value TEXT);
INSERT INTO test (value) VALUES (X'DEADBEEF');
"#)?;
let mut select = c.prepare("SELECT value FROM test")?;
assert_eq!(select.column_type(0), ValueType::NULL);
assert!(select.step()?.is_row());
assert_eq!(select.column_type(0), ValueType::BLOB);
assert!(select.step()?.is_done());Sourcepub const NULL: Self
pub const NULL: Self
The null type.
§Examples
use sqll::{Connection, ValueType};
let mut c = Connection::open_in_memory()?;
c.execute(r#"
CREATE TABLE test (value);
INSERT INTO test (value) VALUES (NULL);
"#)?;
let mut select = c.prepare("SELECT value FROM test")?;
assert_eq!(select.column_type(0), ValueType::NULL);
assert!(select.step()?.is_row());
assert_eq!(select.column_type(0), ValueType::NULL);
assert!(select.step()?.is_done());Trait Implementations§
Source§impl Display for ValueType
Display implementation for ValueType.
impl Display for ValueType
Display implementation for ValueType.
§Examples
use sqll::ValueType;
assert_eq!(ValueType::INTEGER.to_string(), "INTEGER");
assert_eq!(ValueType::FLOAT.to_string(), "FLOAT");
assert_eq!(ValueType::TEXT.to_string(), "TEXT");
assert_eq!(ValueType::BLOB.to_string(), "BLOB");
assert_eq!(ValueType::NULL.to_string(), "NULL");impl Copy for ValueType
impl Eq for ValueType
impl StructuralPartialEq for ValueType
Auto Trait Implementations§
impl Freeze for ValueType
impl RefUnwindSafe for ValueType
impl Send for ValueType
impl Sync for ValueType
impl Unpin for ValueType
impl UnsafeUnpin 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