bytecodealliance / bytecodealliance/wac

Add `Package::from_wit` convenience

Open
#92 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
208
Forks
41
Avg merge
2d 7h
Merged PRs (30d)
3

Description

It would be nice to have some sort of convenience for declaring a `wac_types::Package` from wit files.

Essentially replacing this code:

```rust
let mut resolve = wit_parser::Resolve::new();
let pkg = if path.is_dir()
let (pkg, _) = resolve.push_dir(path)?;
pkg
} else {
let unresolved = wit_parser::UnresolvedPackage::parse_file(&path)?;
resolve.push(unresolved)?
};
let bytes = wit_component::encode(Some(true), &resolve, pkg)?;
wac_graph::types::Package::from_bytes(
name,
None,
bytes.to_owned(),
types,
)
```

Of course, this ties `wac_types` to the convention from `wit_parser`, but the `wac_cli` already does this, so I don't see why it would be inappropriate in `wac_types`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.