Alexandre Courbot
2025-Aug-28 11:26 UTC
[PATCH v2 1/8] rust: transmute: add `from_bytes_copy` method to `FromBytes` trait
On Tue Aug 26, 2025 at 1:07 PM JST, Alexandre Courbot wrote:> `FromBytes::from_bytes` comes with a few practical limitations: > > - It requires the bytes slice to have the same alignment as the returned > type, which might not be guaranteed in the case of a byte stream, > - It returns a reference, requiring the returned type to implement > `Clone` if one wants to keep the value for longer than the lifetime of > the slice. > > To overcome these when needed, add a `from_bytes_copy` with a default > implementation in the trait. `from_bytes_copy` returns an owned value > that is populated using an unaligned read, removing the lifetime > constraint and making it usable even on non-aligned byte slices. > > Reviewed-by: Alice Ryhl <aliceryhl at google.com> > Signed-off-by: Alexandre Courbot <acourbot at nvidia.com>We got 3 Reviewed-by on this patch - Miguel, are you ok if I merge it together with Christian's `from_bytes` patch, since they are closely related?
Miguel Ojeda
2025-Aug-28 11:45 UTC
[PATCH v2 1/8] rust: transmute: add `from_bytes_copy` method to `FromBytes` trait
On Thu, Aug 28, 2025 at 1:26?PM Alexandre Courbot <acourbot at nvidia.com> wrote:> > We got 3 Reviewed-by on this patch - Miguel, are you ok if I merge it > together with Christian's `from_bytes` patch, since they are closely > related?If you are taking this series this cycle, then sure! Acked-by: Miguel Ojeda <ojeda at kernel.org> Thanks! Cheers, Miguel
Alexandre Courbot
2025-Aug-29 01:51 UTC
[PATCH v2 1/8] rust: transmute: add `from_bytes_copy` method to `FromBytes` trait
On Thu Aug 28, 2025 at 8:45 PM JST, Miguel Ojeda wrote:> On Thu, Aug 28, 2025 at 1:26?PM Alexandre Courbot <acourbot at nvidia.com> wrote: >> >> We got 3 Reviewed-by on this patch - Miguel, are you ok if I merge it >> together with Christian's `from_bytes` patch, since they are closely >> related? > > If you are taking this series this cycle, then sure! > > Acked-by: Miguel Ojeda <ojeda at kernel.org>Thanks Miguel! Pushed this into nova-next, right after Christian's patch.