Re: [PATCH v4] Add methods for FromBytes trait.
From: Christian
Date: Mon Mar 17 2025 - 19:15:11 EST
Hi, Benno.
> It usually is a good idea to include a changelog and a link to any prior
> versions after this `---`. It won't be included in the final commit
> message, but help reviewers and others keep track of this series.
Yeah, my bad. I forgot.
> I think this section should go before the `Safety` section.
I followed this section:
https://docs.kernel.org/rust/coding-guidelines.html#code-documentation,
but no problem, I'll change.
> Why is this trait becoming safe?
I thought that if we change to a Result and get the Err case, it's not
a problem to be safe.
> IMO it makes more sense for the return type to be `Option<&Self>`.
I agree. I'll change.
> This must also require that `Self: AsBytes`, since otherwise the user
> could write padding bytes into the original slice.
Did you mean `ToBytes`? Should I create another patch with an empty trait, e.g
```
unsafe trait ToBytes {}
```
or create the trait and its methods?
> Also the parameter name `mut_slice_of_bytes` is a bit long, how about
> `bytes`?
I liked it, I'll change to `bytes` and `bytes_mut`
> What is this safety comment for?
Idk if I should create another safety comment or just continue. In
this case, I choose the first and submit the patch. So how should I
proceed?
Thanks,
Christian