{"id":18535787,"url":"https://github.com/ohkami-rs/worker-bindings","last_synced_at":"2025-04-09T15:32:47.301Z","repository":{"id":246000483,"uuid":"819809185","full_name":"ohkami-rs/worker-bindings","owner":"ohkami-rs","description":"Automatically detect Cloudflare Workers bindings in wrangler.toml and bind them to a Rust struct","archived":false,"fork":false,"pushed_at":"2024-11-08T20:06:04.000Z","size":23,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T08:54:41.327Z","etag":null,"topics":["cloudflare","cloudflare-workers","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/worker-bindings","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/ohkami-rs.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-25T08:40:21.000Z","updated_at":"2024-11-08T20:05:04.000Z","dependencies_parsed_at":"2024-06-29T18:51:39.898Z","dependency_job_id":null,"html_url":"https://github.com/ohkami-rs/worker-bindings","commit_stats":null,"previous_names":["kana-rus/worker-bindings","ohkami-rs/worker-bindings"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohkami-rs%2Fworker-bindings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohkami-rs%2Fworker-bindings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohkami-rs%2Fworker-bindings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ohkami-rs%2Fworker-bindings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ohkami-rs","download_url":"https://codeload.github.com/ohkami-rs/worker-bindings/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248058187,"owners_count":21040714,"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":["cloudflare","cloudflare-workers","rust"],"created_at":"2024-11-06T19:27:30.854Z","updated_at":"2025-04-09T15:32:47.295Z","avatar_url":"https://github.com/ohkami-rs.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eworker-bindings\u003c/h1\u003e\n\u003cp align=\"center\"\u003eAutomatically detect \u003cem\u003ebindings\u003c/em\u003e in \u003ccode\u003ewrangler.toml\u003c/code\u003e and bind them to a Rust struct\u003c/p\u003e\n\n\u003cdiv align=\"right\"\u003e\n    \u003ca href=\"https://github.com/ohkami-rs/worker-bindings/blob/main/LICENSE\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/crates/l/worker-bindings.svg\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/ohkami-rs/worker-bindings/actions\"\u003e\u003cimg alt=\"CI status\" src=\"https://github.com/ohkami-rs/worker-bindings/actions/workflows/CI.yaml/badge.svg\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://crates.io/crates/worker-bindings\"\u003e\u003cimg alt=\"crates.io\" src=\"https://img.shields.io/crates/v/worker-bindings\" /\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n## Example\n\n*wrangler.toml*\n```toml\n[vars]\nMY_VAR = \"my-variable\"\n\n[[kv_namespaces]]\nbinding = \"MY_KV\"\nid      = \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"\n```\n\n*lib.rs*\n```rust\nuse worker::*;\nuse worker_bindings::bindings;\n\n/* This knows all your bindings in wrangler.toml */\n#[bindings]\nstruct Bindings;\n\n#[event(fetch)]\npub async fn main(req: Request, env: Env, _ctx: worker::Context) -\u003e Result\u003cResponse\u003e {\n    /* load bindings from env */\n    let b = Bindings::from(\u0026env);\n\n    let var: \u0026'static str = b.MY_VAR;\n\n    let data = b.MY_KV.get(\"data\").text().await?;\n\n    //...\n}\n```\n\n## Note\n\n- `#[bindings]` works in a cargo workspace but has a limitation that it can't resolve `wrangler.toml` if **more than one** members have `wrangler.toml`s.\n- This crate is originally developed in [Ohkami](https://crates.io/crates/ohkami) web framework and later extracted as an independent edition.\n\n## License\n`worker-bindings` is licensed under the MIT License ([LICENSE](https://github.com/ohkami-rs/worker-bindings/blob/main/LICENSE) or [https://opensource.org/licenses/MIT](https://opensource.org/licenses/MIT)).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohkami-rs%2Fworker-bindings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fohkami-rs%2Fworker-bindings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fohkami-rs%2Fworker-bindings/lists"}