Name | hyperbeepy JSON |
Version |
0.3.1
JSON |
| download |
home_page | |
Summary | Peer to Peer B-tree |
upload_time | 2024-03-19 19:39:54 |
maintainer | |
docs_url | None |
author | |
requires_python | |
license | MIT OR Apache-2.0 |
keywords |
dat
p2p
btree
hypercore
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Hyperbee
A peer-to-peer append-only B-tree built on Hypercore. Compatible with the [JavaScript version](https://github.com/holepunchto/hyperbee).
```
$ cargo add hyperbee
```
# Usage
From the [examples](/examples/ram.rs):
```rust
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](https://mozilla.github.io/uniffi-rs/) to generate libraries for other languages. To build the library for python run:
```bash
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](tests/python.rs) for example usage.
## Parity with JS Hyperbee
- [x] full functional interoperability with JS Hyperbee files
- [x] read, write, and delete operations
- [x] in-order key streaming like JS's [`createReadStream`](https://docs.holepunch.to/building-blocks/hyperbee#const-stream-db.createreadstream-range-options)
- [x] support `gt`, `lt`, etc bounds for key streaming
- [x] accept compare-and-swap for `put` and `del`.
- [x] support prefixed key operations like JS's [`sub`](https://docs.holepunch.to/building-blocks/hyperbee#const-sub-db.sub-sub-prefix-options)
- [ ] one-to-one binary output
## Future work
- [x] Build FFI wrappers
- [ ] improved wire format
- [ ] configurable tree parameters
## Development
Run the tests with `$ cargo test`.
Raw data
{
"_id": null,
"home_page": "",
"name": "hyperbeepy",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "dat,p2p,btree,hypercore",
"author": "",
"author_email": "",
"download_url": "",
"platform": null,
"description": "# Hyperbee\n\nA peer-to-peer append-only B-tree built on Hypercore. Compatible with the [JavaScript version](https://github.com/holepunchto/hyperbee).\n```\n$ cargo add hyperbee\n```\n\n# Usage\n\nFrom the [examples](/examples/ram.rs):\n\n```rust\nuse hyperbee::Hyperbee;\n\n#[tokio::main]\nasync fn main() -> Result<(), Box<dyn std::error::Error>> {\n let hb = Hyperbee::from_ram().await?;\n // Insert \"world\" with key \"hello\"\n hb.put(b\"hello\", Some(b\"world\")).await?;\n\n // Get the value for key \"hello\"\n let Some((_seq, Some(val))) = hb.get(b\"hello\").await? else {\n panic!(\"could not get value\");\n };\n assert_eq!(val, b\"world\");\n\n // Trying to get a non-exsitant key returns `None`\n let res = hb.get(b\"no key here\").await?;\n assert_eq!(res, None);\n\n // Deleting a key returns `true` if it was present\n let res = hb.del(b\"hello\").await?;\n assert!(res.is_some());\n\n // Getting deleted key returns `None`\n let res = hb.get(b\"hello\").await?;\n assert_eq!(res, None);\n\n Ok(())\n}\n```\n\n## Foreign Language Bindings\n\nWe use [UniFFI](https://mozilla.github.io/uniffi-rs/) to generate libraries for other languages. To build the library for python run:\n```bash\ncargo build -F ffi && cargo run -F ffi --bin uniffi-bindgen generate --library target/debug/libhyperbee.so --language python --out-dir out\n```\nThis generates a file `out/hyperbee.py`, which an be used. This file requires that `libhyperbee.so` be present alongside the `.py` file.\nDistributable python packages are still a work-in-progress. Currently only Python is tested. See [the tests](tests/python.rs) for example usage.\n\n## Parity with JS Hyperbee\n\n- [x] full functional interoperability with JS Hyperbee files\n- [x] read, write, and delete operations\n- [x] in-order key streaming like JS's [`createReadStream`](https://docs.holepunch.to/building-blocks/hyperbee#const-stream-db.createreadstream-range-options)\n- [x] support `gt`, `lt`, etc bounds for key streaming\n- [x] accept compare-and-swap for `put` and `del`.\n- [x] support prefixed key operations like JS's [`sub`](https://docs.holepunch.to/building-blocks/hyperbee#const-sub-db.sub-sub-prefix-options)\n- [ ] one-to-one binary output\n\n## Future work\n\n- [x] Build FFI wrappers\n- [ ] improved wire format\n- [ ] configurable tree parameters\n\n## Development\n\nRun the tests with `$ cargo test`.\n\n",
"bugtrack_url": null,
"license": "MIT OR Apache-2.0",
"summary": "Peer to Peer B-tree",
"version": "0.3.1",
"project_urls": {
"Source Code": "https://github.com/cowlicks/hyperbee"
},
"split_keywords": [
"dat",
"p2p",
"btree",
"hypercore"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8c851c69a4fe786a51121c3efa5edced17805555157330a07dd77137c4b3a63b",
"md5": "aab0608c189b86b538be56b3b0728496",
"sha256": "6cd141c333301391ee5a45cf83121b276c840ee8a09ac0b49b9d3fe0acc7548d"
},
"downloads": -1,
"filename": "hyperbeepy-0.3.1-py3-none-manylinux_2_34_x86_64.whl",
"has_sig": false,
"md5_digest": "aab0608c189b86b538be56b3b0728496",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 19849735,
"upload_time": "2024-03-19T19:39:54",
"upload_time_iso_8601": "2024-03-19T19:39:54.991356Z",
"url": "https://files.pythonhosted.org/packages/8c/85/1c69a4fe786a51121c3efa5edced17805555157330a07dd77137c4b3a63b/hyperbeepy-0.3.1-py3-none-manylinux_2_34_x86_64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-19 19:39:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cowlicks",
"github_project": "hyperbee",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "hyperbeepy"
}