lists/
lists.rs

1use candystore::{CandyStore, Config, Result};
2
3fn main() -> Result<()> {
4    let db = CandyStore::open("/tmp/candy-dir", Config::default())?;
5
6    // clear the DB just in case we has something there before. in real-life scenarios you would probably
7    // not clear the DB every time
8    db.clear()?;
9
10    db.set_in_list("asia", "iraq", "arabic")?;
11    db.set_in_list("asia", "china", "chinese")?;
12    db.set_in_list("asia", "russia", "russian")?;
13
14    db.set_in_list("europe", "spain", "spanish")?;
15    db.set_in_list("europe", "italy", "italian")?;
16    db.set_in_list("europe", "greece", "greek")?;
17
18    for res in db.iter_list("asia") {
19        let (k, v) = res?;
20        println!(
21            "{} => {}",
22            String::from_utf8(k).unwrap(),
23            String::from_utf8(v).unwrap()
24        )
25    }
26
27    // iraq => arabic
28    // china => chinese
29    // russia => russian
30
31    Ok(())
32}