KvListBuilder

Struct KvListBuilder 

Source
pub struct KvListBuilder { /* private fields */ }
Expand description

Builder for flexible queries over a key/value backend.

Use prefix, start, and end keys to define your query range, then call KvListBuilder::entries.

§Examples

use stupid_simple_kv::{Kv, MemoryBackend, KvValue, IntoKey};
let mut kv = Kv::new(Box::new(MemoryBackend::new()));

// List all pairs with prefix (1, _)
let pairs = kv.list().prefix(&(1u64,)).entries().unwrap();

// Range scan from (99,2) up to (99,5)
let result = kv.list().start(&(99u64, 2i64)).end(&(99u64, 5i64)).entries().unwrap();

Implementations§

Source§

impl KvListBuilder

Source

pub fn prefix(&mut self, prefix: &dyn IntoKey) -> &mut Self

Restrict results to the given key prefix.

Source

pub fn start(&mut self, start: &dyn IntoKey) -> &mut Self

Start listing at this key (inclusive).

Source

pub fn end(&mut self, end: &dyn IntoKey) -> &mut Self

End listing at this key (exclusive).

Source

pub fn entries(&self) -> KvResult<Vec<(KvKey, KvValue)>>

Run the current query and return key-value pairs. Returns all results matching the filter/prefix/bounds.

§Errors

Returns an error if the combination of selectors is invalid, or if decoding fails.

Auto Trait Implementations§

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.