Re: [PATCH v3 0/4] Support more safe `AsBytes`/`FromBytes` usage
From: Alexandre Courbot
Date: Wed Apr 29 2026 - 20:27:42 EST
Hi Matthew,
On Sat Dec 27, 2025 at 6:08 AM JST, Matthew Maurer wrote:
> Currently:
> * Slices of `AsBytes`/`FromBytes` types cannot be synthesized from
> bytes slices (without unsafe).
> * Users must use `unsafe impl` to assert that structs are `AsBytes` or
> `FromBytes` and write appropriate justifications.
> * Bindgen-generated types cannot implement `AsBytes` or `FromBytes`,
> meaning that casting them to or from bytes involves assumptions in the
> `unsafe impl` that could easily go out of sync if the underlying
> header is edited or an assumption is invalid on a platform the author
> did not consider.
>
> This series seeks to address all there of these by:
> 1. Adding slice cast functions to `FromBytes`
> 2. Adding a derive for `AsBytes` and `FromBytes`, for now restricted to
> the simple case of structs.
> 3. Refactoring the crate structure to move `AsBytes` and `FromBytes` to
> `ffi` to allow `bindings` and `uapi` to reference them.
> 4. Enabling bindgen derivation in `bindings`/`uapi` through `AsBytesFfi`
> and `FromBytesFfi`.
>
> 1+2 can be landed separately if needed, 3 has no purpose without 4, and
> 3+4 need 1+2.
>
> Signed-off-by: Matthew Maurer <mmaurer@xxxxxxxxxx>
Do you have plans to carry this series on? If not I would be willing to
try and drive it until it can be merged, as it would be very handy to
use in nova-core.