You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WritableToBytes could be replaced by zerocopy::AsBytes #975
The WritableToBytes trait is an unsafe marker trait that is used to indicate that a type's underlying bytes may safely be accessed as a sequence of bytes. This trait appears to perform the same function as zerocopy::AsBytes. zerocopy is a crate dedicated to these sorts of memory access operations, and the AsBytes trait provides a custom derive, allowing code like the following:
#[derive(AsBytes)]#[repr(C)]structGood{a:u16,b:u16,}#[derive(AsBytes)]// Won't compile because of padding byte between `a` and `b`#[repr(C)]structBad{a:u8,b:u16,}
It might be worth considering replacing WritableToBytes with AsBytes.
Disclosure: I'm the author of the zerocopy crate.
This requires submitting a proper patch to the LKML and the Rust for Linux mailing list. Please recall to test your changes (including generating the documentation if changed, running the Rust doctests if changed, etc.), to justify the commit well in the message ("what" & "why"), to use a proper title for the commit, to sign your commit under the Developer's Certificate of Origin and to add a Suggested-by: tag, and a Link: tag to this issue. Please see https://docs.kernel.org/process/submitting-patches.html and https://rust-for-linux.com/contributing for details.
In any case, thanks for contacting us and creating the issue -- if we start to vendor third-party crates in the future (which is not impossible -- there have been some discussions about it, but it will take time), then we will revisit this one as well as other crates.
Activity
nbdd0121 commentedon Feb 23, 2023
We currently don't use/vendor third-party crates.
joshlf commentedon Feb 23, 2023
Ah gotcha. Feel free to close this then.
ojeda commentedon Feb 23, 2023
In any case, thanks for contacting us and creating the issue -- if we start to vendor third-party crates in the future (which is not impossible -- there have been some discussions about it, but it will take time), then we will revisit this one as well as other crates.
domenpk commentedon May 23, 2023
I like the approach, since the trait's user apparently can't misuse it, and there is also no unsafe for safe code.
ojeda commentedon Jun 8, 2026
We ended up with
zerocopyin the tree and:WritableToBytesgot renamed toAsBytesto matchzerocopyback then.zerocopy0.8.0 renamedAsBytestoIntoBytes.rust: debugfs: migrate debugfs traits requirements to zerocopy