{"id":15017993,"url":"https://github.com/johanhelsing/bevy_pkv","last_synced_at":"2025-05-15T18:10:25.518Z","repository":{"id":40394578,"uuid":"470126561","full_name":"johanhelsing/bevy_pkv","owner":"johanhelsing","description":"Cross-platform (including wasm) persistent key value store plugin for rust games/apps","archived":false,"fork":false,"pushed_at":"2025-04-25T08:00:33.000Z","size":99,"stargazers_count":150,"open_issues_count":12,"forks_count":23,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-25T08:02:39.428Z","etag":null,"topics":["bevy","bevy-plugin","key-value","localstorage","persistence","rust","sled","wasm"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johanhelsing.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}},"created_at":"2022-03-15T11:20:33.000Z","updated_at":"2025-04-25T08:00:36.000Z","dependencies_parsed_at":"2025-03-24T23:38:48.725Z","dependency_job_id":null,"html_url":"https://github.com/johanhelsing/bevy_pkv","commit_stats":{"total_commits":124,"total_committers":18,"mean_commits":6.888888888888889,"dds":"0.30645161290322576","last_synced_commit":"79df04ce0ebb0c5880e472dcc2bd85ab670dddba"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johanhelsing%2Fbevy_pkv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johanhelsing%2Fbevy_pkv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johanhelsing%2Fbevy_pkv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johanhelsing%2Fbevy_pkv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johanhelsing","download_url":"https://codeload.github.com/johanhelsing/bevy_pkv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254394724,"owners_count":22063984,"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":["bevy","bevy-plugin","key-value","localstorage","persistence","rust","sled","wasm"],"created_at":"2024-09-24T19:51:17.871Z","updated_at":"2025-05-15T18:10:25.513Z","avatar_url":"https://github.com/johanhelsing.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bevy_pkv\n\n[![crates.io](https://img.shields.io/crates/v/bevy_pkv.svg)](https://crates.io/crates/bevy_pkv)\n![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)\n[![docs.rs](https://img.shields.io/docsrs/bevy_pkv)](https://docs.rs/bevy_pkv)\n[![ci](https://github.com/johanhelsing/bevy_pkv/actions/workflows/ci.yml/badge.svg)](https://github.com/johanhelsing/bevy_pkv/actions/workflows/ci.yml)\n\n`bevy_pkv` is a cross-platform persistent key value store for rust apps.\n\nUse it for storing things like settings, save games etc.\n\nCurrently, the Bevy dependency is optional, so it may be used in other games/apps as well.\n\n## Usage with Bevy\n\nAdd a store resource to your app\n\n```rust no_run\n# #[cfg(feature = \"bevy\")] { // ignore this line\nuse bevy::prelude::*;\nuse bevy_pkv::PkvStore;\n\nfn main() {\nApp::new()\n    .add_plugins(DefaultPlugins)\n    .insert_resource(PkvStore::new(\"FooCompany\", \"BarGame\"))\n    // ...insert systems etc.\n    .run();\n}\n# }\n```\n\nThis will create or load a store in the appropriate location for your system, and make it available to bevy systems:\n\n```rust ignore\nfn setup(mut pkv: ResMut\u003cPkvStore\u003e) {\n    if let Ok(username) = pkv.get::\u003cString\u003e(\"username\") {\n        info!(\"Welcome back {username}\");\n    } else {\n        pkv.set_string(\"username\", \"alice\")\n            .expect(\"failed to store username\");\n\n        // alternatively, using the slightly less efficient generic api:\n        pkv.set(\"username\", \u0026\"alice\".to_string())\n            .expect(\"failed to store username\");\n    }\n}\n```\n\nUsing your own types implementing `serde::Serialize` and `Deserialize`:\n\n```rust ignore\n#[derive(Serialize, Deserialize)]\nstruct User {\n    name: String,\n}\n\nfn setup(mut pkv: ResMut\u003cPkvStore\u003e) {\n    if let Ok(user) = pkv.get::\u003cUser\u003e(\"user\") {\n        info!(\"Welcome back {}\", user.name);\n    } else {\n        let user = User {\n            name: \"bob\".to_string(),\n        };\n        pkv.set(\"user\", \u0026user).expect(\"failed to store user\");\n    }\n}\n```\n\nSee the [examples](./examples) for further usage\n\n## Usage without Bevy\n\nDisable the default features when adding the dependency:\n\n```toml\nbevy_pkv = {version = \"0.9\", default-features = false}\n```\n\n## Implementation details\n\n### Native\n\n`redb` and `rmp_serde` (MessagePack) is used for storage. It's creating a `bevy_pkv.redb` db in the appropriate application data directory for your system.\n\nAlternatively, disable default-features and enable the `rocksdb` feature to use a RocksDB-based implementation or `sled` feature to use sled db.\n\n### Wasm\n\n`Window.localStorage` and `serde_json` is used for storage. Perhaps IndexedDb and something else would have been a better choice, but its API is complicated, and I wanted a simple implementation and a simple synchronous API.\n\n## Bevy version support\n\nThe `main` branch targets the latest bevy release.\n\n|bevy|bevy\\_pkv|\n|----|---|\n|0.16|0.13, main|\n|0.15|0.12|\n|0.14|0.11|\n|0.13|0.10|\n|0.12|0.9|\n|0.11|0.8|\n|0.10|0.7|\n|0.9 |0.6|\n|0.8 |0.5|\n|0.7 |0.2, 0.3, 0.4|\n|0.6 |0.1|\n\n## License\n\nMIT or Apache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohanhelsing%2Fbevy_pkv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohanhelsing%2Fbevy_pkv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohanhelsing%2Fbevy_pkv/lists"}