Skip to content

Add support for lowering directly from Bytes.#13366

Queued
sunfishcode wants to merge 5 commits into
bytecodealliance:mainfrom
sunfishcode:sunfishcode/lower-bytes
Queued

Add support for lowering directly from Bytes.#13366
sunfishcode wants to merge 5 commits into
bytecodealliance:mainfrom
sunfishcode:sunfishcode/lower-bytes

Conversation

@sunfishcode
Copy link
Copy Markdown
Member

Add a "component-model-bytes" feature which enables implementations of ComponentType and Lower for the Bytes type, from the bytes crate.

These will allow optimizing functions that return list<u8> to return Bytes values without converting them to Vec<u8> first.

Zulip thread: #wasmtime > Optimizing `list<u8>` returns in hostcalls @ 💬

Add a "component-model-bytes" feature which enables implementations of
`ComponentType` and `Lower` for the `Bytes` type, from the `bytes` crate.

These will allow optimizing functions that return `list<u8>` to return
`Bytes` values without converting them to `Vec<u8>` first.
@sunfishcode sunfishcode requested a review from a team as a code owner May 14, 2026 15:45
@sunfishcode sunfishcode requested review from pchickey and removed request for a team May 14, 2026 15:45
Copy link
Copy Markdown
Contributor

@pchickey pchickey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This would be a nice optimization to apply to wasmtime-wasi-io by default, in a follow up PR. As of now, it gets no CI testing, idk if we should add something for it in this PR or just count on it being tested via wasmtime-wasi-io in a follow up?

@github-actions github-actions Bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label May 14, 2026
* Consolidate `component-model-async-bytes` feature into
  `component-model-bytes`
* Reformat `Cargo.toml` a bit
* Add some basic tests that `Bytes` and `BytesMut` can be used.
@alexcrichton alexcrichton requested review from a team as code owners June 3, 2026 15:09
@alexcrichton alexcrichton requested review from dicej and fitzgen and removed request for a team June 3, 2026 15:09
@alexcrichton
Copy link
Copy Markdown
Member

@pchickey mind reviewing the changes I've pushed up here?

Copy link
Copy Markdown
Contributor

@pchickey pchickey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tweaks and tests look good, thank you

@alexcrichton alexcrichton added this pull request to the merge queue Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasmtime:api Related to the API of the `wasmtime` crate itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants