#sled #typed #bytes #search-engine #byte

typed-sled

Sled with types instead of bytes

18 releases

0.2.3 Jan 1, 2023
0.2.1 Dec 28, 2022
0.2.0 Dec 7, 2021
0.1.14 Nov 21, 2021
0.1.7 Sep 30, 2021
Download history 159/week @ 2023-02-11 109/week @ 2023-02-18 84/week @ 2023-02-25 110/week @ 2023-03-04 189/week @ 2023-03-11 64/week @ 2023-03-18 67/week @ 2023-03-25 80/week @ 2023-04-01 103/week @ 2023-04-08 81/week @ 2023-04-15 47/week @ 2023-04-22 77/week @ 2023-04-29 100/week @ 2023-05-06 48/week @ 2023-05-13 58/week @ 2023-05-20 81/week @ 2023-05-27

298 downloads per month
Used in 2 crates

MIT license

120KB
2K SLoC

typed-sled - a database build on top of sled

API

sled is a high-performance embedded database with an API that is similar to a BTreeMap<[u8], [u8]>.
typed-sled builds on top of sled and offers an API that is similar to a BTreeMap<K, V>, where K and V are user defined types.

Example

use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
struct SomeValue(u32);

// Creating a temporary sled database
let db = sled::Config::new().temporary(true).open().unwrap();

// The id is used by sled to identify which Tree in the database (db) to open
let tree = typed_sled::Tree::<String, SomeValue>::open(&db, "unique_id");

// insert and get, similar to std's BTreeMap
tree.insert(&"some_key".to_owned(), &SomeValue(10))?;

assert_eq!(tree.get(&"some_key".to_owned())?, Some(SomeValue(10)));
Ok(())


features

Multiple features for common use cases are available:

  • Search engine for searching through a tree's keys and values by using tantivy.
  • Automatic key generation.
  • Custom (de)serialization. By default bincode is used for (de)serialization, however custom (de)serializers are supported, making zero-copy or lazy (de)serialization possible.
  • Converting one typed Tree to another typed Tree with different key and value types.

Dependencies

~2–33MB
~554K SLoC