vsdb-7.0.0 has been yanked.
vsdb
vsdbis a high-performance, embedded database with an API similar to Rust's standard collections.
This crate provides high-level, typed data structures that are backed by a persistent key-value store. It is the primary crate for end-users.
This is a simplified version of the original vsdb, retaining only the most practical and stable parts.
Installation
Add this to your Cargo.toml:
[]
= "7.0.0"
Highlights
For more detailed API examples, see API Examples.
- Familiar API: Most APIs are designed to mirror their counterparts in the standard library.
Vecxbehaves likestd::collections::Vec.Mapxbehaves likestd::collections::HashMap.MapxOrdbehaves likestd::collections::BTreeMap.
- Persistent Storage: Data is automatically saved to disk and loaded on instantiation.
- Typed Keys and Values: Keys and values are strongly typed and automatically serialized/deserialized.
Features
fjall_backend: (Default) Usefjallas 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 data compression in the backend database.
Usage
Vecx
Vecx is a persistent, vector-like data structure.
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 persistent, hash map-like data structure.
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 persistent, B-tree map-like data structure that keeps keys in 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 for distributed consensus. The serialized data contains meta-information (like storage paths) that may differ across environments. The correct approach is to read the required data and then process the raw content. - The
len()of a data structure is not always guaranteed to be absolutely reliable and should be treated as a hint. This is because some operations may not update the length atomically in real-time for performance reasons.
License
This project is licensed under the GPL-3.0 license.