-
Notifications
You must be signed in to change notification settings - Fork 251
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
[wasm-metadata] parse OCI author custom section #1925
Conversation
There was a problem hiding this 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.
801338f
to
06f9aa0
Compare
rewrite_wasm( | ||
&self.name, | ||
&Producers::from_meta(self), | ||
&self.author, | ||
self.registry_metadata.as_ref(), | ||
input, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The number of function arguments will continue to increase until morale improves.
More seriously though: once I finish adding the custom sections, I plan to refactor the way we handle this. I suspect we can combine rewrite_wasm
, Metadata
, and AddMetadata
into a unified structure, allowing us to tidy this up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me, thanks for this!
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
andwasm-encoder
, and I'm for example not sure whetherparse_wasm
should take aBinaryReader
orCustomSectionReader
.Also: I was looking for something like a
Parse
trait, but I don't thinkwasmparser
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!