pub enum ValueRef<'a> {
Null,
Integer(i64),
Real(f64),
Text(&'a [u8]),
Blob(&'a [u8]),
}Expand description
A non-owning dynamic type value. Typically, the memory backing this value is owned by SQLite.
See Value for an owning dynamic type value.
Variants§
Null
The value is a NULL value.
Integer(i64)
The value is a signed integer.
Real(f64)
The value is a floating point number.
Text(&'a [u8])
The value is a text string.
Blob(&'a [u8])
The value is a blob of data
Implementations§
Source§impl<'a> ValueRef<'a>
impl<'a> ValueRef<'a>
Sourcepub fn as_i64(&self) -> Result<i64, FromSqlError>
pub fn as_i64(&self) -> Result<i64, FromSqlError>
If self is case Integer, returns the integral value. Otherwise,
returns Err(Error::InvalidColumnType).
Sourcepub fn as_i64_or_null(&self) -> Result<Option<i64>, FromSqlError>
pub fn as_i64_or_null(&self) -> Result<Option<i64>, FromSqlError>
If self is case Null returns None.
If self is case Integer, returns the integral value.
Otherwise, returns Err(Error::InvalidColumnType).
Sourcepub fn as_f64(&self) -> Result<f64, FromSqlError>
pub fn as_f64(&self) -> Result<f64, FromSqlError>
If self is case Real, returns the floating point value. Otherwise,
returns Err(Error::InvalidColumnType).
Sourcepub fn as_f64_or_null(&self) -> Result<Option<f64>, FromSqlError>
pub fn as_f64_or_null(&self) -> Result<Option<f64>, FromSqlError>
If self is case Null returns None.
If self is case Real, returns the floating point value.
Otherwise, returns Err(Error::InvalidColumnType).
Sourcepub fn as_str(&self) -> Result<&'a str, FromSqlError>
pub fn as_str(&self) -> Result<&'a str, FromSqlError>
If self is case Text, returns the string value. Otherwise, returns
Err(Error::InvalidColumnType).
Sourcepub fn as_str_or_null(&self) -> Result<Option<&'a str>, FromSqlError>
pub fn as_str_or_null(&self) -> Result<Option<&'a str>, FromSqlError>
If self is case Null returns None.
If self is case Text, returns the string value.
Otherwise, returns Err(Error::InvalidColumnType).
Sourcepub fn as_blob(&self) -> Result<&'a [u8], FromSqlError>
pub fn as_blob(&self) -> Result<&'a [u8], FromSqlError>
If self is case Blob, returns the byte slice. Otherwise, returns
Err(Error::InvalidColumnType).
Sourcepub fn as_blob_or_null(&self) -> Result<Option<&'a [u8]>, FromSqlError>
pub fn as_blob_or_null(&self) -> Result<Option<&'a [u8]>, FromSqlError>
If self is case Null returns None.
If self is case Blob, returns the byte slice.
Otherwise, returns Err(Error::InvalidColumnType).
Sourcepub fn as_bytes(&self) -> Result<&'a [u8], FromSqlError>
pub fn as_bytes(&self) -> Result<&'a [u8], FromSqlError>
Returns the byte slice that makes up this ValueRef if it’s either
ValueRef::Blob or ValueRef::Text.
Sourcepub fn as_bytes_or_null(&self) -> Result<Option<&'a [u8]>, FromSqlError>
pub fn as_bytes_or_null(&self) -> Result<Option<&'a [u8]>, FromSqlError>
If self is case Null returns None.
If self is ValueRef::Blob or ValueRef::Text returns the byte
slice that makes up this value
Trait Implementations§
Source§impl AsSqlTy for ValueRef<'_>
impl AsSqlTy for ValueRef<'_>
Source§type Borrowed<'p> = ValueRef<'p>
type Borrowed<'p> = ValueRef<'p>
Self, e.g.
for trivially-copiable types such as integers and floats).
This is used e.g. for constructing the Table::PrimaryKey
associated type, which in turn serves as the input type of
helper queries such as SelectByKey and DeleteByKey.Source§fn format_check_constraint(
column: &dyn Display,
formatter: &mut Formatter<'_>,
) -> Result
fn format_check_constraint( column: &dyn Display, formatter: &mut Formatter<'_>, ) -> Result
column argument. If
the body of this function doesn’t write anything to the
formatter, no CHECK constraint is going to be emitted. Read more