bytecodealliance / bytecodealliance/wit-bindgen
Types appearing both in module and in exports
- Lingua principale
- Rust
- Stelle
- 1.5k
- Fork
- 286
- Merge medio
- 6h 32m
- PR unite (30g)
- 19
Descrizione
Consider this wit
```wit
package litehouse:plugin;
interface plugin {
variant update {
time(u64),
temperature(float64),
wind-speed(float64),
current(float64),
voltage(u16),
power(u16),
on-off(bool),
}
}
world plugin-host {
use plugin.{update};
import send-update: func(nickname: string, update: update);
export plugin;
}
```
I want to simultaneously expose the interface to the host as well as require the host to expose a function for the guest to use. The generated code however produces two types, `bindings::litehouse::plugin::plugin::Update` and `bindings::exports::litehouse::plugin::plugin::Update`, one presumably stems from the `use` and one from the `export`. These generated types are (to my eyes) identical. Any `Update` coming from the guest has the first, and any `Update` going into the guest has the latter. I would assume we would be able to, in the case of an interface being exported, defer all references of it to its exported types. Is there a technical reason for not doing this? If it is some technical issue, then a From / Into each way would be handy.
I will note it looks like all types from the interface are generated in both `bindings` and `bindings::exports` despite only importing one of them. I would also imagine those would be pruned to just the ones that are explicitly `use`d plus types they reference.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia con l’esempio WIT fornito e ispeziona i bindings generati alla ricerca dei tipi Update duplicati in bindings e bindings::exports. Traccia il modo in cui le dichiarazioni use ed export producono questi tipi, quindi determina se i riferimenti possono condividere i tipi esportati o necessitano di conversioni From/Into. Il lavoro è completato quando l’API generata non espone più tipi duplicati non necessari e le interazioni previste tra host e guest sono preservate.
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