cargo-component
cargo-component copied to clipboard
move generated bindings files to a `generated/` sub-directory
This is a small pet-peeve of mine but I figured I'd raise it: I find the name src/bindings.rs
to be a little ambiguous, as it assumes people are already familiar with how WIT, Wasm Components, and wasm-bindgen
work. It also assumes that people seeing the file in the hierarchy understand that this was auto-generated and was not checked in by hand. I feel like we would be better served by clearer labeling that this file is automatically generated, and specific to Wasm Components - not just any old bindings. This is doubly the case when we consider that people might generate bindings to other things, for example: it's not unreasonable for someone to generate bindings to a protobuf schema, and then wire that over wasi:sockets
.
What I'm proposing here are two relatively minor changes:
- Create a directory called
src/generated/
which we recommend using as the output target for all generated code. - Rename the
bindings.rs
file to something slightly more descriptive. Something likewasm_bindings
orcomponent_bindings
could more clearly clue in people unfamiliar with Wasm Components about what is going on.
If we put those two together, that would result in a rename like src/bindings.rs
→ src/generated/component_bindings.rs
. A little longer, but more clearly factored in a way that makes it clear we're not supposed to edit this by hand.
This is clearly a "what color do we paint the bike shed" type of question, which is why I've put this off raising this for a while. But it feels like we're in the home stretch of delivering an end-to-end story, and I've recently seen at least one person be confused about the purpose of bindings.rs
, so I figured raising this now might actually be reasonable timing.