Auto-generated bindings
Now that @mrbbot has added support for doing this in TypeScript (https://github.com/cloudflare/workers-types/pull/112), we have the infrastructure for doing this for Rust too. He actually did both but the Rust one just hasn't been integrated. Not sure what actually needs to be done here but opening this issue just to track it.
cc @nilslice for visibility.
Nice! Yea, the plan has always been to use the auto-generated ones, not sure if the generated Rust made it into the PR or if we decided to host other language types / declarations elsewhere.
The first step would be to replace at least one module from the worker-sys crate in this repo with its equivalent from the generated Rust.
Questions: (for anyone involved here, not just @vlovich :) )
- where do we want to keep the generated Rust? Different repo per language output? All together in a monorepo? Not sure what the process is to export the IR and other generated code from internal repos.. so that might influence the decision.
- is there already a plugin/process to generate Rust, or was the initial attempt more of a proof-of-concept?
- we need to publish the generated code to crates.io, which is currently being done manually from this repo, but eventually there will be automation - so it would be great to decided on 1 & 2 above before adding the automation. Not that big of a deal if it's a late-add though.
Hey! 👋 These are my thoughts:
- I think it makes sense to keep workers-types TypeScript (as it always has been), putting the generated Rust in this repo. Although with the way new types are published at the moment (GitHub PR, see below), it might make sense to lump them in the same repo so only one approval/merge is required per week.
- There's already a process to generate the Rust: it's currently behind a command-line flag on the internal generation tool. I was able to build a simple worker with the output, it's just not been tested with the rest of this project yet.
- For the workers-types repo, we currently have an automation that commits and PRs the changes with each release. We're not publishing to npm just yet, but we could definitely do this automatically. Maybe we could have a GitHub action that publishes to npm/crates.io on merge?