| Crates.io | mergedb-types |
| lib.rs | mergedb-types |
| version | 0.1.0 |
| created_at | 2026-01-11 12:06:20.713124+00 |
| updated_at | 2026-01-11 12:06:20.713124+00 |
| description | CRDT data structures for mergeDB |
| homepage | |
| repository | https://github.com/mergedb-rs/mergeDB |
| max_upload_size | |
| id | 2035663 |
| size | 22,226 |
The core library of Conflict-free Replicated Data Types (CRDTs) powering MergeDB.
This crate provides the fundamental data structures that allow MergeDB nodes to diverge and converge automatically without a central coordinator. These types are designed to be state-based, eventually consistent, and partition-tolerant.
A distributed counter that supports both increment and decrement operations.
P for increments, N for decrements) per node ID.Value = ΣP - ΣN.An Observed-Remove Set (OR-Set) optimized for an "Add-Wins" strategy.
add_tags map and has not been fully covered by the remove_tags tombstones.A simple register for storing string values (like keys in a standard KV store).
Add this to your Cargo.toml:
[dependencies]
mergedb-types = "0.1.0"
use mergedb_types::{PNCounter, Merge};
fn main() {
let node_a = "node_a".to_string();
let node_b = "node_b".to_string();
let mut counter_a = PNCounter::new();
counter_a.increment(node_a.clone(), 10);
let mut counter_b = PNCounter::new();
counter_b.increment(node_b.clone(), 20);
// Simulate network sync
counter_a.merge(&mut counter_b);
assert_eq!(counter_a.value(), 30);
}
This crate maintains a high standard of unit testing to ensure convergence properties (associativity, commutativity, and idempotence) are met.
To run the standard test suite:
cargo test -p mergedb-types
recommend to use cargo-tarpaulin to verify code coverage
# Install tarpaulin
cargo install cargo-tarpaulin
# Generate Coverage Report
cargo tarpaulin -p mergedb-types --out Html
This will generate a tarpaulin-report.html file that visualizes which lines of your CRDT logic are covered by tests.
This project is licensed under the MIT License.