WebAssembly / WebAssembly/component-model
Implement resource converters
Nobody has claimed this yet.
- Dominant language
- WebAssembly
- Stars
- 1.4k
- Forks
- 130
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 15
Description
Hi --
I'm trying to create a resource in a component that can be constructed from values of different types. I could use a variant as an argument, but it would be nice if I could overload the constructor of a resource somehow so that idiomatic ways to construct a resource from various different types could be provided.
For instance, if we could do something like this:
resource blob {
from(string);
from(list<u8> as byte-array);
from(types.descriptor);
from(types.input-stream);
from(types.output-stream);
...
}
This could generate something like this in the guest trait (or whatever the equivalent, of course):
pub trait GuestBlob: 'static {
fn from_string(String) -> Blob;
fn from_byte_array(Vec<u8>) -> Blob;
fn from_descriptor(filesystem::types::Descriptor) -> Blob;
...
}
Then these convenience trait implementations (or whatever equivalent in another language, even if that means nothing as one could use the static methods as they are) would be present:
impl From<String> for Blob {
fn from(other: String) -> Self {
Self::from_string(other)
}
}
impl From<Vec<u8>> for Blob {
...
}
impl From<filesystem::types::Descriptor> for Blob {
...
}
...
Thoughts on this?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files, tests, or entry points; begin by reviewing the component-model resource and type-conversion design discussions. Done means reaching a decided specification for resource conversion syntax and its generated guest-language behavior, with implementation locations and validation work identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100