Skip to main content

ValueList

Struct ValueList 

Source
pub struct ValueList<'list> { /* private fields */ }
Expand description

Represents a list of values from SQLite.

SQLite provides these when a virtual table is processing all values of an IN constraint simultaneously, see IndexInfoConstraint::set_value_list_wanted for more information.

This struct is not an Iterator by itself. There are two recommended ways to interact with it. The first is a while let:

use sqlite3_ext::*;

fn filter_list(list: &mut ValueRef) -> Result<()> {
    let mut list = ValueList::from_value_ref(list)?;
    while let Some(x) = list.next()? {
        println!("value is {:?}", x);
    }
    Ok(())
}

Alternatively, the map method turns this struct into a FallibleIterator:

use sqlite3_ext::*;

fn filter_list(list: &mut ValueRef) -> Result<()> {
    let list: Vec<String> = ValueList::from_value_ref(list)?
        .map(|x| Ok(x.get_str()?.to_owned()))
        .collect()?;
    println!("values are {:?}", list);
    Ok(())
}

Implementations§

Source§

impl<'list> ValueList<'list>

Source

pub fn from_value_ref(base: &'list mut ValueRef) -> Result<Self>

Attempt to create a ValueList from a ValueRef.

§Safety

The SQLite documentation states that using this method outside of the VTabCursor::filter method is “undefined and probably harmful”. However, since the feature’s introduction, the underlying mechanism has always (as of SQLite 3.38.5) used the pointer passing interface and is therefore be safe to use with any ValueRef (although such a use will result in an Err).

Requires SQLite 3.38.0.

Trait Implementations§

Source§

impl FallibleIteratorMut for ValueList<'_>

Source§

type Item = ValueRef

The type of item being iterated.
Source§

type Error = Error

The type of error that can be returned by this iterator.
Source§

fn next(&mut self) -> Result<Option<&mut Self::Item>>

Works like FallibleIterator::next, except instead of returning Self::Item, it returns &mut Self::Item.
Source§

fn size_hint(&self) -> (usize, Option<usize>)

Source§

fn map<F, B>(&mut self, f: F) -> Map<'_, Self, F>
where Self: Sized, F: FnMut(&mut Self::Item) -> Result<B, Self::Error>,

Convert this iterator into a FallibleIterator by applying a function to each element.

Auto Trait Implementations§

§

impl<'list> Freeze for ValueList<'list>

§

impl<'list> RefUnwindSafe for ValueList<'list>

§

impl<'list> !Send for ValueList<'list>

§

impl<'list> !Sync for ValueList<'list>

§

impl<'list> Unpin for ValueList<'list>

§

impl<'list> UnsafeUnpin for ValueList<'list>

§

impl<'list> !UnwindSafe for ValueList<'list>

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<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.