{"id":31847913,"url":"https://github.com/wireapp/redb-opfs","last_synced_at":"2025-10-12T09:58:31.580Z","repository":{"id":311939962,"uuid":"1045583600","full_name":"wireapp/redb-opfs","owner":"wireapp","description":"Implements a redb `StorageBackend` over OPFS","archived":false,"fork":false,"pushed_at":"2025-09-19T15:57:56.000Z","size":63,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-19T17:51:26.368Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wireapp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-27T12:07:07.000Z","updated_at":"2025-08-28T07:10:04.000Z","dependencies_parsed_at":"2025-08-28T00:29:54.322Z","dependency_job_id":"3b5128a6-2a92-4aab-a22f-d24cbf64125b","html_url":"https://github.com/wireapp/redb-opfs","commit_stats":null,"previous_names":["wireapp/redb-opfs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wireapp/redb-opfs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wireapp%2Fredb-opfs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wireapp%2Fredb-opfs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wireapp%2Fredb-opfs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wireapp%2Fredb-opfs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wireapp","download_url":"https://codeload.github.com/wireapp/redb-opfs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wireapp%2Fredb-opfs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279010951,"owners_count":26084841,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-12T09:58:29.709Z","updated_at":"2025-10-12T09:58:31.575Z","avatar_url":"https://github.com/wireapp.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `redb-opfs`: Implements a `StorageBackend` which delegates to OPFS\n\nThis allows deployment on `wasm32-unknown-unknown`.\n\n\u003e [!WARNING]\n\u003e The contents of this README are a statement of intent, not an accurate reflection of the current state of\n\u003e the project.\n\u003e\n\u003e Carefully inspect the code and/or generated documentation before relying on this library.\n\n## Usage\n\nIt is important to understand that Redb's [`StorageBackend`\ninterface](https://docs.rs/redb/latest/redb/trait.StorageBackend.html) is fundamentally synchronous, and OPFS is\nfundamentally asynchronous. There's a simple way to tie these two things\ntogether--[`block_on`](https://docs.rs/futures-lite/latest/futures_lite/future/fn.block_on.html)--but that method is\nillegal on the main thread, in order not to block the UI.\n\n\u003e [!IMPORTANT]\n\u003e The `OpfsBackend` instance **must** run on a web worker.\n\nThis gives rise to two use cases.\n\n### Your Rust code is already running in a web worker\n\nThis case is nice and simple; everything stays within Rust. Just explicitly choose this backend when initializing your\n`Database`:\n\n```rust\nuse redb_opfs::OpfsBackend;\n\nlet database = redb::Builder::new()\n  .create_with_backend(OpfsBackend::new(\"my-db\")?)?;\n```\n\n### Your Rust code is running in the main thread\n\n\u003e [!NOTE]\n\u003e Running in this configuration introduces unavoidable performance penalties; when possible, you should prefer\n\u003e to run all your Rust code within a web worker to avoid these.\n\nIn this case we need to instantiate the `OpfsBackend` on a web worker and then instantiate the handle on the main\nthread.\n\nYou'll want to use the `worker-shim.js` worker file to initialize the worker, and then hand that worker to the\n`OpfsBackendHandle`\n\n```js\nimport { WorkerHandle } from \"./redb-opfs\";\n\nconst redbOpfsWorker = new Worker(\"worker-shim.js\");\nconst workerHandle = WorkerHandle(redbOpfsWorker);\n\n// now pass that handle to your rust code, using a mechanism of your choice.\n```\n\nAs you're writing your own Rust anyway, you have your own means of getting the handle into your code from there. To keep\nlife simple, there exists `impl TryFrom\u003cJsValue\u003e for WorkerHandle`.\n\nOnce you have that, usage is fairly simple:\n\n```rust\nuse redb_opfs::WorkerHandle;\n\nlet worker_handle = WorkerHandle::try_from(my_js_value)?;\nlet database = redb::Builder::new()\n  .create_with_backend(worker_hanndle)?;\n```\n\n## Building\n\n### Prerequisites for WASM\n\n- [`wasm-bindgen` cli](https://github.com/wasm-bindgen/wasm-bindgen?tab=readme-ov-file#install-wasm-bindgen-cli)\n- [wasm-pack](https://github.com/drager/wasm-pack)\n- [GNU Make](https://www.gnu.org/software/make/)\n\n## Examples\n\n### Web Worker\n\nThis example demonstrates the simplest possible case: `redb-opfs` is compiled to WASM and deployed, where it is used\nonly from Typescript code without interacting at all with other Rust code. In this use case, the only thing it gives us\nis a fully-synchronous interface to OPFS.\n\n#### Prerequisites\n\n- [bun](https://bun.com/)\n- [miniserve](https://github.com/svenstaro/miniserve)\n\n#### Usage\n\n- `make web-worker-example`\n- point your browser at any of the listed URLs the server has bound itself to\n\n### Rust in Web Worker\n\nThis example demonstrates the first \"real\" use case: a Rust library uses redb internally.\nThe rust code is all exclusively contained within the web worker.\n\nThe application is a toy click tracker: records the timestamp of each click of a button.\nReports the total number of clicks, and n clicks over some aggregated time periods.\n\n#### Prerequisites\n\n- [bun](https://bun.com/)\n- [miniserve](https://github.com/svenstaro/miniserve)\n\n#### Usage\n\n- `make rust-in-web-worker-example`\n- point your browser at any of the listed URLs the server has bound itself to\n\n## License\n\nLicensed only under [GPL-3.0](./LICENSE).\n\n### Contribution\n\nAny contribution intentionally submitted for inclusion in this work shall be licensed as above, without any additional\nterms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwireapp%2Fredb-opfs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwireapp%2Fredb-opfs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwireapp%2Fredb-opfs/lists"}