| Crates.io | hyperbee |
| lib.rs | hyperbee |
| version | 0.5.0 |
| created_at | 2024-02-12 01:29:31.75764+00 |
| updated_at | 2024-08-25 03:07:18.463087+00 |
| description | Peer to Peer B-tree |
| homepage | |
| repository | https://github.com/cowlicks/hyperbee |
| max_upload_size | |
| id | 1136318 |
| size | 245,376 |
A peer-to-peer append-only B-tree built on Hypercore. Compatible with the JavaScript version.
$ cargo add hyperbee
From the examples:
use hyperbee::Hyperbee;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let hb = Hyperbee::from_ram().await?;
// Insert "world" with key "hello"
hb.put(b"hello", Some(b"world")).await?;
// Get the value for key "hello"
let Some((_seq, Some(val))) = hb.get(b"hello").await? else {
panic!("could not get value");
};
assert_eq!(val, b"world");
// Trying to get a non-exsitant key returns `None`
let res = hb.get(b"no key here").await?;
assert_eq!(res, None);
// Deleting a key returns `true` if it was present
let res = hb.del(b"hello").await?;
assert!(res.is_some());
// Getting deleted key returns `None`
let res = hb.get(b"hello").await?;
assert_eq!(res, None);
Ok(())
}
We use UniFFI to generate libraries for other languages. To build the library for python run:
cargo build -F ffi && cargo run -F ffi --bin uniffi-bindgen generate --library target/debug/libhyperbee.so --language python --out-dir out
This generates a file out/hyperbee.py, which an be used. This file requires that libhyperbee.so be present alongside the .py file.
Distributable python packages are still a work-in-progress. Currently only Python is tested. See the tests for example usage.
createReadStreamgt, lt, etc bounds for key streamingput and del.subRun the tests with $ cargo test.
Each significant pull request should include an update the CHANGELOG.md
Releases are mostly handled with cargo release.
After each Rust release. We manually release a new python package. Building the python package is done with maturin and it is released with twine.
# create a virtualenv with the tools we need
python -m venv venv && . venv/bin/activate
pip install --upgrade twine maturin
# build the wheels
python -m maturin build --release
# Upload the wheels to pypi. This uses my api token from ~/.pypirc
python -m twine upload target/wheels/hyperbeepy-<target>.whl