VSDB is a 'Git' in the form of KV-database.
Based on the powerful version control function of VSDB, you can easily give your data structure the ability to version management.
Make everything versioned !!
To view the change log check here.
Vecx
just like Vec
Mapx
just like HashMap
MapxOrd
just like BTreeMap
CheckTx
, DeliverTx
, Commit
... in 'Tendermint ABCI'Suppose you have a great algorithm like this:
rust
struct GreatAlgo {
a: Vec<...>,
b: BTreeMap<...>,
c: u128,
d: HashMap<...>,
e: ...
}
Simply replace the original structure with the corresponding VSDB data structure, and your algorithm get the powerful version control ability at once!
```rust
struct GreatAlgo {
a: VecxVs<...>,
b: MapxOrdVs<...>,
c: OrphanVs
let algo = GreatAlgo::default();
algo.getbybranchversion(...); algo.branchcreate(...); algo.branchcreatebybasebranch(...); algo.branchcreatebybasebranchversion(...); algo.branchremove(...); algo.version_pop(...); algo.prune(); ```
NOTE !!
the #[derive(Vs)]
macro can be applied to structures
whose internal fields are all types defined in VSDB
(primitive types and their collections are also supported),
but can not be applied to nesting wrapper among VSDB-types,
we recommend you to use the multi-key APIs
if you indeed require these functions(better performance also),
or you will have to implement the VsMgmt
trait manually.
This data structure can be handled correctly by #[derive(Vs)]
:
```rust
struct GoodCase
struct SubItem0(MapxVs
struct SubItem1 {
a: OrphanVs
struct SubItem2 { a: i8, b: u128 }
// // A nope implementation of VsMgmt
for custom stateless types.
// // the #[derive(Vs)]
on 'SubItem2' is same as this implementation.
// impl VsMgmt for SubItem2 {
// implvsmethods_nope!();
// }
```
But this one can NOT be handled correctly by #[derive(Vs)]
:
```rust
// It can be compiled, but the result is wrong !
// The versioned methods of the inner 'MapxVs
struct BadCase {
a: VecxVs
Please check the multi-key functions if you have requirements of the above or similar scenes.
Some complete examples:
sled_engine
, use sled as the backend database
rocks_engine
, use rocksdb as the backend database
msgpack_codec
, use msgpack as the codec
bcs_codec
, use bcs as the codec
derive
, enable the Vs
procedural macrocompress
, enable compression in the backend databaseextra_types
, implement VsMgmt
for some common extra types
H256
and H160
of the primitive-types
crateNone
to []
since v0.42.0
[u8;0]
, &[]
...) to a key, the key will be treated as 'deleted'