pub struct Text { /* private fields */ }Expand description
Type implementation for a text column.
This is represented in rust by the Text value and corresponds to the
TEXT runtime-time type.
This type is NotNull, use Nullable<Text> to make it nullable.
§Examples
use sqll::{Connection, FromColumn, Result, Statement};
use sqll::ty;
#[derive(Debug, PartialEq, Eq)]
struct MyString<'stmt>(&'stmt str);
impl<'stmt> FromColumn<'stmt> for MyString<'stmt> {
type Type = ty::Text;
#[inline]
fn from_column(stmt: &'stmt Statement, index: ty::Text) -> Result<Self> {
Ok(MyString(<_>::from_column(stmt, index)?))
}
}
let c = Connection::open_in_memory()?;
c.execute(r#"
CREATE TABLE test (value TEXT);
INSERT INTO test (value) VALUES ('Hello, world!');
"#)?;
let mut stmt = c.prepare("SELECT value FROM test")?;
assert_eq!(stmt.next::<MyString>()?, Some(MyString("Hello, world!")));Implementations§
Trait Implementations§
Source§impl Type for Text
Type implementation for a text column.
impl Type for Text
Type implementation for a text column.
§Examples
use sqll::{Connection, FromColumn, Result, Statement};
use sqll::ty;
#[derive(Debug, PartialEq, Eq)]
struct MyString<'stmt>(&'stmt str);
impl<'stmt> FromColumn<'stmt> for MyString<'stmt> {
type Type = ty::Text;
#[inline]
fn from_column(stmt: &'stmt Statement, index: ty::Text) -> Result<Self> {
Ok(MyString(<_>::from_column(stmt, index)?))
}
}
let c = Connection::open_in_memory()?;
c.execute(r#"
CREATE TABLE test (value TEXT);
INSERT INTO test (value) VALUES ('Hello, world!');
"#)?;
let mut stmt = c.prepare("SELECT value FROM test")?;
assert_eq!(stmt.next::<MyString>()?, Some(MyString("Hello, world!")));impl NotNull for Text
Text values cannot be null.
ty::Nullable<ty::Text>§Examples
use sqll::{Connection, Code};
let mut c = Connection::open_in_memory()?;
c.execute(r#"
CREATE TABLE nulls (value);
INSERT INTO nulls (value) VALUES (NULL);
"#)?;
let mut select = c.prepare("SELECT value FROM nulls")?;
let e = select.next::<&str>().unwrap_err();
assert_eq!(e.code(), Code::MISMATCH);Auto Trait Implementations§
impl Freeze for Text
impl RefUnwindSafe for Text
impl Send for Text
impl Sync for Text
impl Unpin for Text
impl UnsafeUnpin for Text
impl UnwindSafe for Text
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