[][src]Trait sledis::list::ListWriteStore

pub trait ListWriteStore: ListReadStore + WriteStore {
    fn list_push_front<V>(&self, name: &[u8], val: V) -> Result<(), Self::Error>
    where
        IVec: From<V>
;
fn list_push_back<V>(&self, name: &[u8], val: V) -> Result<(), Self::Error>
    where
        IVec: From<V>
;
fn list_pop_front(&self, name: &[u8]) -> Result<Option<IVec>, Self::Error>;
fn list_pop_back(&self, name: &[u8]) -> Result<Option<IVec>, Self::Error>;
fn list_set<V>(
        &self,
        name: &[u8],
        ix: u64,
        val: V
    ) -> Result<Option<IVec>, Self::Error>
    where
        IVec: From<V>
; }

This trait provides deque semantics for the lists in ListReadStore.

Example Initialization

use sledis::{ListReadStore, ListWriteStore};
use sled::Config;

let tree = Config::new().temporary(true).open().unwrap();

// A new empty list
let list_meta_data = tree.list_get_meta(b"my_list").unwrap();
assert_eq!(list_meta_data.len(), 0);
assert_eq!(tree.list_len(b"my_list").unwrap(), 0);

// pushing and popping from the front
tree.list_push_front(b"my_list", b"oof").unwrap();
assert_eq!(tree.list_len(b"my_list").unwrap(), 1);
assert_eq!(tree.list_pop_front(b"my_list").unwrap().unwrap(), b"oof");
assert_eq!(tree.list_len(b"my_list").unwrap(), 0);

// and the back
tree.list_push_back(b"my_list", b"oof").unwrap();
assert_eq!(tree.list_len(b"my_list").unwrap(), 1);
assert_eq!(tree.list_pop_back(b"my_list").unwrap().unwrap(), b"oof");
assert_eq!(tree.list_len(b"my_list").unwrap(), 0);

Required methods

fn list_push_front<V>(&self, name: &[u8], val: V) -> Result<(), Self::Error> where
    IVec: From<V>, 

fn list_push_back<V>(&self, name: &[u8], val: V) -> Result<(), Self::Error> where
    IVec: From<V>, 

fn list_pop_front(&self, name: &[u8]) -> Result<Option<IVec>, Self::Error>

fn list_pop_back(&self, name: &[u8]) -> Result<Option<IVec>, Self::Error>

fn list_set<V>(
    &self,
    name: &[u8],
    ix: u64,
    val: V
) -> Result<Option<IVec>, Self::Error> where
    IVec: From<V>, 

Loading content...

Implementors

impl<S> ListWriteStore for S where
    S: WriteStore + ListReadStore,
    S::Error: From<Error>, 
[src]

Loading content...