Struct Ref

Source
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>>§

Source

pub fn value_type(&self) -> Result<Type>

Returns the type of the contained value.

Source

pub fn size(&self) -> Result<usize>

For non-scalar types, returns the size of the data.

Depending on the contained type, returns:

  • String and Binary: length of the string or binary string;
  • Array: number of elements.
Source

pub fn is_null(&self) -> bool

Returns true if the value is an SQL null value.

Source

pub fn is_true(&self) -> bool

Returns true if the value is a boolean true value, or a non-zero integer.

Source

pub fn to_i64(&self) -> Result<i64>

Casts the value to i64.

Strings are parsed and converted, if possible; otherwise an error is returned.

Source

pub fn to_real(&self) -> Result<f64>

Casts the value to f64.

Strings are parsed and converted, if possible; otherwise an error is returned.

Source

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.

Source

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.

Source

pub fn to_numeric(&self) -> Result<Numeric>

Returns the contained fixed-width numeric value, if any, or an error.

Source

pub fn to_string(&self) -> Result<String>

Converts the value to the string representation.

Source

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.

Source

pub fn to_binary(&self) -> Result<Vec<u8>>

Returns a copy of the bytes of a string or a binary value.

Source

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.

Source

pub fn as_array(&self) -> Result<&Array<'_>>

Casts the value to Array if it has the Array type; returns an error otherwise.

Source

pub fn as_sequence(&self) -> Result<&Sequence<'_>>

Casts the value to Sequence if it has the Sequence type; returns an error otherwise.

Source

pub fn as_blob(&self) -> Result<&Blob<'_>>

Casts the value to Blob if it has the Blob type; returns an error otherwise.

Trait Implementations§

Source§

impl<'a> Deref for Ref<'a>

Source§

type Target = Value<'a>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a> Drop for Ref<'a>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Ref<'a>

§

impl<'a> RefUnwindSafe for Ref<'a>

§

impl<'a> !Send for Ref<'a>

§

impl<'a> !Sync for Ref<'a>

§

impl<'a> Unpin for Ref<'a>

§

impl<'a> UnwindSafe for Ref<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.