pub struct Ref<'a> { /* private fields */ }
Expand description
An SQL value reference.
In addition to the value itself, a value reference holds a reference to the value’s allocator, making it possible to release the value when the reference goes out of scope.
Methods from Deref<Target = Value<'a>>§
Sourcepub fn value_type(&self) -> Result<Type>
pub fn value_type(&self) -> Result<Type>
Returns the type of the contained value.
Sourcepub fn size(&self) -> Result<usize>
pub fn size(&self) -> Result<usize>
For non-scalar types, returns the size of the data.
Depending on the contained type, returns:
String
andBinary
: length of the string or binary string;Array
: number of elements.
Sourcepub fn is_true(&self) -> bool
pub fn is_true(&self) -> bool
Returns true
if the value is a boolean true
value, or a non-zero
integer.
Sourcepub fn to_i64(&self) -> Result<i64>
pub fn to_i64(&self) -> Result<i64>
Casts the value to i64
.
Strings are parsed and converted, if possible; otherwise an error is returned.
Sourcepub fn to_real(&self) -> Result<f64>
pub fn to_real(&self) -> Result<f64>
Casts the value to f64
.
Strings are parsed and converted, if possible; otherwise an error is returned.
Sourcepub fn to_date_time(&self) -> Result<u64>
pub fn to_date_time(&self) -> Result<u64>
Casts the value to the number of system ticks elapsed since the beginning of the epoch.
String values are parsed using strptime()
where available, or a
compatible custom function.
Sourcepub fn to_system_time(&self) -> Result<SystemTime>
pub fn to_system_time(&self) -> Result<SystemTime>
Casts the value to the number of system ticks elapsed since
the beginning of the epoch, and converts the resulting value to
std::time::SystemTime
.
Sourcepub fn to_numeric(&self) -> Result<Numeric>
pub fn to_numeric(&self) -> Result<Numeric>
Returns the contained fixed-width numeric value, if any, or an error.
Sourcepub fn as_str(&self) -> Result<&str>
pub fn as_str(&self) -> Result<&str>
Returns a string slice pointing to the contents of a String
value,
or an error if the value is not a String
.
Sourcepub fn to_binary(&self) -> Result<Vec<u8>>
pub fn to_binary(&self) -> Result<Vec<u8>>
Returns a copy of the bytes of a string or a binary value.
Sourcepub fn as_bytes(&self) -> Result<&[u8]>
pub fn as_bytes(&self) -> Result<&[u8]>
Returns a byte slice pointing to the contents of a Binary
value,
or an error if the value is not a Binary
.
Sourcepub fn as_array(&self) -> Result<&Array<'_>>
pub fn as_array(&self) -> Result<&Array<'_>>
Casts the value to Array
if it has the Array
type; returns
an error otherwise.
Sourcepub fn as_sequence(&self) -> Result<&Sequence<'_>>
pub fn as_sequence(&self) -> Result<&Sequence<'_>>
Casts the value to Sequence
if it has the Sequence
type; returns
an error otherwise.