bytecodealliance / bytecodealliance/wit-bindgen

rust: Support a more terse form of `with`-based remapping

Aperta
#840 4 commenti 0 reazioni 0 assegnatari Vedi su GitHub
gen-rust
Lingua principale
Rust
Stelle
1.5k
Fork
286
Merge medio
6h 32m
PR unite (30g)
19

Descrizione

Currently `with` works by operating at the `interface` level, requiring a specification such as:

```rust
generate!({
with: {
"pkg:foo/bar": path::to::module,
}
});
```

This can get cumbersome for a suite of packages, however:

```rust
generate!({
with: {
"pkg:a/b1": ...,
"pkg:a/b2": ...,
"pkg:a/b3": ...,
"pkg:b/b1": ...,
"pkg:b/b2": ...,
"pkg:c/b1": ...,
...
}
});
```

I've seen this come up in the context of WASI where a bunch of WASI interfaces are referenced but the types to use should come from somewhere else. Especially with the `wasi` crate nowadays I think it should be easier to use the `wasi` crate wholesale. I'm imagining something like:

```rust
generate!({
with: {
"wasi": wasi, // refers to `wasi`-the-crate
}
});
```

I'm also thinking you could do:

```rust
generate!({
with: {
"wasi:cli": wasi::cli,
"wasi:io": wasi::io,
}
});
```

Where the general idea is that of the "path" that's `pkg:a/b` you could start chopping off pieces from the right and generate `pkg:a` and `pkg`. Both cases would be considered as covering all "children" of those namespaces, meaning that if `pkg:a` were specified then any interface in the `pkg:a` package would use the `with` key for `pkg:a`. The projections from that key would use the standard naming scheme that `wit-bindgen` already uses.

Ideally I'd like to see this ported to the `wasmtime::component::bindgen!` macro eventually too.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia tracciando il modo in cui la configurazione `with` esistente viene gestita da `generate!` e il modo in cui i relativi percorsi a livello di interfaccia vengono proiettati. Determina le regole di fallback dei namespace per i prefissi di package e namespace, quindi valida le forme proposte `wasi`, `wasi:cli` e `wasi:io`; anche la compatibilità futura con `wasmtime::component::bindgen!` fa parte dell’obiettivo dichiarato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust, wasm
Ambito
tooling
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.