Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wasm-metadata] parse OCI author custom section #1925

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

yoshuawuyts
Copy link
Member

This PR adds support for parsing the author custom section, implementing parts of #1922. Thanks!

Draft Notes

I'm filing this PR early and as a draft because I'm not 100% sure I'm following best practices here. It's my first time using wasmparser and wasm-encoder, and I'm for example not sure whether parse_wasm should take a BinaryReader or CustomSectionReader.

Also: I was looking for something like a Parse trait, but I don't think wasmparser has one? I quite liked the encoder side of things.

Finally: in this PR I'm basically just wrapping CustomSection in a newtype - however that means storing the internal data as a byte array rather than a string. How do we feel about that?

I'm asking these questions since I'm planning to repeat this pattern a number of times for the other custom sections, and it seems worth making sure it's early on. Thanks!

Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Thanks for this! What I might recommend is to take the &[u8] entire wasm in memory as opposed to just a custom section. That way you can bake in how to handle a missing section, duplicated sections, the section name, etc. Internally you can use a BinaryReader to parse the binary data if necessary, but yeah the Parse-trait side of things is sort of there with FromReader but it's no the same as the encoding side of things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants