-
Notifications
You must be signed in to change notification settings - Fork 156
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
Missing API surface after move from bytemuck::Pod #294
Comments
The switch to our own
I'm fine with adding mutable variants of the API if you need it. I'm unsure how this is intended to interact with the rest of the object file parsing though, which expects to hold multiple references to parts of the file (something that is harder to manage with mutable references). |
May I ask you to elaborate on this? Bytemuck seems pretty easy to implement to me. |
If I implemented bytemuck for this crate in a PR would you consider merging it in? (possibly behind a feature gate to avoid a required dependency?) As for how this would interact with parsing, I expect that the file would have to be re-parsed after each modification. The objective here is really just to leverage object's type definitions etc. |
The implementation in 2d48743 wasn't much larger than the wrappers it replaced. bytemuck handles a more general case (converting between any types, not just byte slices), which adds complexity that we don't need.
You'll have to convince me that it isn't enough to add |
from_bytes_mut and slice_from_bytes_mut would probably satisfy requirements, and I'll happily close this issue. |
Oops, may also request bytes_of_mut as well? |
Sure, curious what you need that for though? I expected mutation via the fields to be enough. |
It's for screwing around and patching elf files mostly, there will likely be corruption of the fields / overlapping etc, so being able to work with raw bytes some of the time helps. |
Recently I have implemented a POD struct, but i've been struck with a dilemma of using
You can ignore bytemuck's complexity except for implementing
POD is POD anywhere you go. Nothing stops you from implementing current Also i think there's some benefit of bringing back bytemuck such as:
I would also like to see |
All that said i would like to do the PR for any of these changes, if any of them are approved. |
You can add an optional dependency on |
@zetanumbers I see you left a confused emoji, so maybe this helps:
If you want pod support for types defined in an unrelated crate, then bytemuck is probably the correct choice, and lack of endian support in bytemuck is something that should be fixed in bytemuck or another crate. |
I aim to edit object files directly in memory using this library, however I've encountered the problem that the object Pod implementation is missing much of the bytemuck::Pod functionality - including the operations on mutable references which would be required for this.
I also notice that the object::pod API is also slightly different:
A Move to bytemuck::Pod would break this API, however the functions that include a tail seem to only be used to implement the Bytes struct (a wrapper around a slice), and this same implementation could also be easily modified to work with bytemuck::Pod and its tail-less functions simply by subslicing the input slice before passing it into the function.
The tail-inclusive functionality could also be added into bytemuck for added ecosystem impact.
I was also able to locate this PR from a year ago #184 which doesn't seem to really justify the switch to a vendored Pod trait...
The text was updated successfully, but these errors were encountered: