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 hypercore 0.0.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 hypercore 0.0.1
File Interpreter ABI Platform Actions
hypercore-0.0.1-py3-none-manylinux_2_34_x86_64.whl Python 3 none Linux glibc 2.34+ x86-64 Details for hypercore-0.0.1-py3-none-manylinux_2_34_x86_64.whl

Release files / hypercore-0.0.1-py3-none-manylinux_2_34_x86_64.whl

Download URL hypercore-0.0.1-py3-none-manylinux_2_34_x86_64.whl
Size 1.4 MB
Tags Linux glibc 2.34+ x86-64 Python 3
SHA-256 checksum
How to use checksums
1ecfad0b3060f496e60dbcb177095713467efb41545ef9f7ed5c38f134f3488c
BLAKE2b-256 checksum
How to use checksums
89301492be4433b2e5baa0a13b761c8f59ee88a67a0db62a8ce0b668baef996d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.8

Security for hypercore 0.0.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.0.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