{"id":15597138,"url":"https://github.com/alorel/rust-indexed-db","last_synced_at":"2025-05-16T09:05:40.577Z","repository":{"id":44531282,"uuid":"382173570","full_name":"Alorel/rust-indexed-db","owner":"Alorel","description":"Future bindings for IndexedDB via web_sys","archived":false,"fork":false,"pushed_at":"2025-05-12T16:32:42.000Z","size":239,"stargazers_count":57,"open_issues_count":2,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-16T09:05:34.430Z","etag":null,"topics":["idb","indexed-db","indexeddb","rust","wasm","web-assembly","webassembly"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Alorel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["Alorel"],"custom":["https://paypal.me/alorel"]}},"created_at":"2021-07-01T22:48:35.000Z","updated_at":"2025-05-11T14:04:33.000Z","dependencies_parsed_at":"2023-02-19T09:45:32.507Z","dependency_job_id":"4d1831c0-f595-409e-ac72-f7a62309923f","html_url":"https://github.com/Alorel/rust-indexed-db","commit_stats":{"total_commits":65,"total_committers":8,"mean_commits":8.125,"dds":0.5076923076923077,"last_synced_commit":"2143e156d72e4894541b27998d4060ec3204f09a"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alorel%2Frust-indexed-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alorel%2Frust-indexed-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alorel%2Frust-indexed-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alorel%2Frust-indexed-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alorel","download_url":"https://codeload.github.com/Alorel/rust-indexed-db/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254501557,"owners_count":22081528,"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","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":["idb","indexed-db","indexeddb","rust","wasm","web-assembly","webassembly"],"created_at":"2024-10-03T01:20:35.398Z","updated_at":"2025-05-16T09:05:35.568Z","avatar_url":"https://github.com/Alorel.png","language":"Rust","funding_links":["https://github.com/sponsors/Alorel","https://paypal.me/alorel"],"categories":[],"sub_categories":[],"readme":"Wraps the [web_sys](https://crates.io/crates/web_sys) Indexed DB API in a Future-based API and\nremoves the pain of dealing with JS callbacks or `JSValue` in Rust.\n\n[![master CI badge](https://github.com/Alorel/rust-indexed-db/actions/workflows/test.yml/badge.svg)](https://github.com/Alorel/rust-indexed-db/actions/workflows/test.yml)\n[![crates.io badge](https://img.shields.io/crates/v/indexed_db_futures)](https://crates.io/crates/indexed_db_futures)\n[![docs.rs badge](https://img.shields.io/docsrs/indexed_db_futures?label=docs.rs)](https://docs.rs/indexed_db_futures)\n[![dependencies badge](https://img.shields.io/librariesio/release/cargo/indexed_db_futures)](https://libraries.io/cargo/indexed_db_futures)\n\nGoals \u0026 features:\n\n- **Shield you from having to interact with [`web_sys`](https://crates.io/crates/web-sys) or\n  [`js_sys`](https://crates.io/crates/js-sys) APIs** - this should feel like a native Rust API.\n- **Integrate with [`serde`](https://crates.io/crates/serde), but don't require it** - as a rule of thumb, you'll use\n  `serde`-serialisable types when working with JS objects \u0026 bypass `serde` for Javascript primitives.\n- **Implement [`Stream`](https://docs.rs/futures/0.3.31/futures/prelude/trait.Stream.html) where applicable** - cursors\n  and key cursors have this at the time of writing.\n- **Implement a more Rust-oriented API** - for example, transactions will roll back by default unless explicitly\n  committed to allow you to use `?`s.\n\n```rust\nuse indexed_db_futures::database::Database;\nuse indexed_db_futures::prelude::*;\nuse indexed_db_futures::transaction::TransactionMode;\n\n#[derive(serde::Serialize, serde::Deserialize)]\nstruct MySerdeType(u8, String);\n\nasync fn main() -\u003e indexed_db_futures::OpenDbResult\u003c()\u003e {\n    let db = Database::open(\"my_db\")\n        .with_version(2u8)\n        .with_on_upgrade_needed(|event, db| {\n            match (event.old_version(), event.new_version()) {\n                (0.0, Some(1.0)) =\u003e {\n                    db.create_object_store(\"my_store\")\n                        .with_auto_increment(true)\n                        .build()?;\n                }\n                (prev, Some(2.0)) =\u003e {\n                    if prev == 1.0 {\n                        let _ = db.delete_object_store(\"my_store\");\n                    }\n\n                    db.create_object_store(\"my_other_store\").build()?;\n                }\n                _ =\u003e {}\n            }\n\n            Ok(())\n        })\n        .await?;\n\n    // Populate some data\n    let transaction = db\n        .transaction(\"my_other_store\")\n        .with_mode(TransactionMode::Readwrite)\n        .build()?;\n\n    let store = transaction.object_store(\"my_other_store\")?;\n\n    store\n        .put(\"a primitive value that doesn't need serde\")\n        .await?;\n\n    // awaiting individual requests is optional - they still go out\n    store.put(MySerdeType(10, \"foos\".into())).serde()?;\n\n    // Unlike JS, transactions ROLL BACK INSTEAD OF COMMITTING BY DEFAULT\n    transaction.commit().await?;\n\n    // Read some data\n    let transaction = db.transaction(\"my_other_store\").build()?;\n    let store = transaction.object_store(\"my_other_store\")?;\n    let Some(mut cursor) = store.open_cursor().await? else {\n        // `None` is returned if the cursor is empty\n        return Ok(());\n    };\n\n    loop {\n        match cursor.next_record_ser::\u003cMySerdeType\u003e().await {\n            Ok(Some(record)) =\u003e handle_record(record),\n            Ok(None) =\u003e break,\n            Err(e) =\u003e handle_error(e),\n        }\n    }\n\n    Ok(())\n}\n```\n\nHead over to the docs for a proper introduction!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falorel%2Frust-indexed-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falorel%2Frust-indexed-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falorel%2Frust-indexed-db/lists"}