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) -> FromSqlResult<i64>
pub fn as_i64(&self) -> FromSqlResult<i64>
If self
is case Integer
, returns the integral value. Otherwise,
returns Err(FromSqlError::InvalidType)
.
Sourcepub fn as_i64_or_null(&self) -> FromSqlResult<Option<i64>>
pub fn as_i64_or_null(&self) -> FromSqlResult<Option<i64>>
If self
is case Null
returns None.
If self
is case Integer
, returns the integral value.
Otherwise, returns Err(FromSqlError::InvalidType)
.
Sourcepub fn as_f64(&self) -> FromSqlResult<f64>
pub fn as_f64(&self) -> FromSqlResult<f64>
If self
is case Real
, returns the floating point value. Otherwise,
returns Err(FromSqlError::InvalidType)
.
Sourcepub fn as_f64_or_null(&self) -> FromSqlResult<Option<f64>>
pub fn as_f64_or_null(&self) -> FromSqlResult<Option<f64>>
If self
is case Null
returns None.
If self
is case Real
, returns the floating point value.
Otherwise, returns Err(FromSqlError::InvalidType)
.
Sourcepub fn as_str(&self) -> FromSqlResult<&'a str>
pub fn as_str(&self) -> FromSqlResult<&'a str>
If self
is case Text
, returns the string value. Otherwise, returns
Err(FromSqlError::InvalidType)
.
Sourcepub fn as_str_or_null(&self) -> FromSqlResult<Option<&'a str>>
pub fn as_str_or_null(&self) -> FromSqlResult<Option<&'a str>>
If self
is case Null
returns None.
If self
is case Text
, returns the string value.
Otherwise, returns Err(FromSqlError::InvalidType)
.
Sourcepub fn as_blob(&self) -> FromSqlResult<&'a [u8]>
pub fn as_blob(&self) -> FromSqlResult<&'a [u8]>
If self
is case Blob
, returns the byte slice. Otherwise, returns
Err(FromSqlError::InvalidType)
.
Sourcepub fn as_blob_or_null(&self) -> FromSqlResult<Option<&'a [u8]>>
pub fn as_blob_or_null(&self) -> FromSqlResult<Option<&'a [u8]>>
If self
is case Null
returns None.
If self
is case Blob
, returns the byte slice.
Otherwise, returns Err(FromSqlError::InvalidType)
.
Sourcepub fn as_bytes(&self) -> FromSqlResult<&'a [u8]>
pub fn as_bytes(&self) -> FromSqlResult<&'a [u8]>
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) -> FromSqlResult<Option<&'a [u8]>>
pub fn as_bytes_or_null(&self) -> FromSqlResult<Option<&'a [u8]>>
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§
impl<'a> Copy for ValueRef<'a>
impl<'a> StructuralPartialEq for ValueRef<'a>
Auto Trait Implementations§
impl<'a> Freeze for ValueRef<'a>
impl<'a> RefUnwindSafe for ValueRef<'a>
impl<'a> Send for ValueRef<'a>
impl<'a> Sync for ValueRef<'a>
impl<'a> Unpin for ValueRef<'a>
impl<'a> UnwindSafe for ValueRef<'a>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 24 bytes
Size for each variant:
Null
: 0 bytesInteger
: 8 bytesReal
: 8 bytesText
: 16 bytesBlob
: 16 bytes