vsdb
A std-collection-like database.
This is a simplified version of the original vsdb, retaining only the most practical and stable parts. This crate provides high-level APIs.
To view the change log check here.
Installation
Add this to your Cargo.toml:
[]
= "4.0.1"
Highlights
- Most APIs are similar to the corresponding data structures in the standard library:
- Use
Vecxjust likeVec. - Use
Mapxjust likeHashMap. - Use
MapxOrdjust likeBTreeMap.
- Use
Features
parity_backend: (Default) Useparity-dbas the backend database. Pure Rust implementation.rocks_backend: Userocksdbas the backend database. C++ implementation.msgpack_codec: (Default) Usermp-serdeas the codec for faster performance.json_codec: Useserde_jsonas the codec for better compatibility.compress: (Default) Enable compression in the backend database.
Usage
Vecx
Vecx is a vector-like data structure that stores values in a contiguous sequence.
use Vecx;
let mut vec = new;
// Push some values
vec.push;
vec.push;
vec.push;
// Get a value
assert_eq!;
// Iterate over the values
for value in vec.iter
// Pop a value
assert_eq!;
assert_eq!;
Mapx
Mapx is a hash map-like data structure that stores key-value pairs.
use Mapx;
let mut map = new;
// Insert some key-value pairs
map.insert;
map.insert;
// Get a value
assert_eq!;
// Check if a key exists
assert!;
// Iterate over the key-value pairs
for in map.iter
// Remove a key-value pair
map.remove;
assert_eq!;
MapxOrd
MapxOrd is a B-tree map-like data structure that stores key-value pairs in a sorted order.
use MapxOrd;
let mut map = new;
// Insert some key-value pairs
map.insert;
map.insert;
map.insert;
// Get a value
assert_eq!;
// Iterate over the key-value pairs in sorted order
for in map.iter
// Get the first and last key-value pairs
assert_eq!;
assert_eq!;
Important Notes
- The serialized result of a
vsdbinstance cannot be used as the basis for distributed consensus. The serialized result only contains meta-information (like storage paths) which may differ across environments. The correct approach is to read the required data and then process the actual content. - The instance
lenis not absolutely reliable and should be regarded as a hint.
License
This project is licensed under the GPL-3.0 license.