Repository navigation
Replace AsSliceU8 trait with zerocopy::AsBytes #692
Description
Activity
Hi @mkroening! @scotran and I are part of a Virtualization course at UT Austin, and as part of a project we have to contribute to open source repositories. Can we take up this issue?
Sure, do you want to do all three issues?
PS: To assign @scotran, he has to be a participant of this issue. Just write anything, then I can add him as well.
Reacted by Joanne ChenYep, all three issues would be great!
Hi @mkroening! I was able to switch the VirtioNetHdr (currently reflected in the pull request created) from implementing AsSliceU8 to deriving AsBytes, but I ran into an issue when trying to change from AsSliceU8 to AsBytes for the Cmd and Rsp structs (https://github.com/hermitcore/libhermit-rs/blob/master/src/fs/fuse.rs#L293): #[derive(AsBytes)] is not supported on types with type parameters. Digging around, there seems to be a workaround (google/zerocopy#10), but this would require using repr(transparent), which then cannot be used alongside repr(C) or repr(packed), which would strip padding and possibly cause alignment issue.
I just wanted to touch base first as to whether this would be the desired approach, and if so, I can continue looking into how to derive AsBytes for structs with type parameters.
- added 7 commits that reference this issue
on Apr 20, 2023 Just as an aside, there is a proposal for
DynSized, with a very similar purpose to ourAsSliceU8: rust-lang/rfcs#3536AsSliceU8was removed with #1316. I think we can close this issue.Reacted by Martin KröningSuperseded by #1316
Padding is uninitialized: Glossary - Unsafe Code Guidelines Reference
We do not check for padding, neither is
AsSliceU8unsafe.zerocopy::AsBytesperforms these checks.