Skip to main content

Hyperbee

A peer-to-peer append-only B-tree built on Hypercore. Compatible with the JavaScript version.

$ cargo add hyperbee

Usage

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(())
}

Foreign Language Bindings

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.

Parity with JS Hyperbee

  • full functional interoperability with JS Hyperbee files
  • read, write, and delete operations
  • in-order key streaming like JS's createReadStream
  • support gt, lt, etc bounds for key streaming
  • accept compare-and-swap for put and del.
  • support prefixed key operations like JS's sub
  • one-to-one binary output

Future work

  • Build FFI wrappers
  • improved wire format
  • configurable tree parameters

Development

Run the tests with $ cargo test.

Metadata

Release files for hyperbeepy 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for hyperbeepy 0.3.1
File Interpreter ABI Platform Actions
hyperbeepy-0.3.1-py3-none-manylinux_2_34_x86_64.whl Python 3 none Linux glibc 2.34+ x86-64 Details for hyperbeepy-0.3.1-py3-none-manylinux_2_34_x86_64.whl

Release files / hyperbeepy-0.3.1-py3-none-manylinux_2_34_x86_64.whl

Download URL hyperbeepy-0.3.1-py3-none-manylinux_2_34_x86_64.whl
Size 19.8 MB
Tags Linux glibc 2.34+ x86-64 Python 3
SHA-256 checksum
How to use checksums
6cd141c333301391ee5a45cf83121b276c840ee8a09ac0b49b9d3fe0acc7548d
BLAKE2b-256 checksum
How to use checksums
8c851c69a4fe786a51121c3efa5edced17805555157330a07dd77137c4b3a63b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.8

Security for hyperbeepy 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.3.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page