Adam Perry would like Owners Override to review this change.
[zx][rs] Align all VMO read calls to use FromBytes.
u8 already satisfies this trait so this is strictly more general.
This change does require adding some turbofishes in places where
Rust's type inference can no longer unambiguously pick a type.
Leaves the Vmo::read() call still using raw bytes to avoid needing
to call drop_in_place when we don't know if the call will succeed.
Requires callers to use `T: Copy` to avoid footguns about missed
`Drop` calls. Seems like all of the current callers of higher level
methods like read_to_vec are fine with this bound. We can always
revisit if we find it difficult to use in practice.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
what's the motivation here? is this tied to a bug? is it tied to a Rust requirement? is it tied to bug-prone patterns?
/// Provides the thinnest wrapper possible over `zx_vmo_read`.
is this still true?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
what's the motivation here? is this tied to a bug? is it tied to a Rust requirement? is it tied to bug-prone patterns?
https://fxrev.dev/1361058 is a bit of background.
We already have `Vmo::read_to_array`, but it requires size to be a constant. I was going to add `read_to_boxed_slice`, and Adam suggested we do this instead.
It's nice to encapsulate unsafe code in a well-vetted library like this, which is one argument for this change. Otherwise, clients who wish to do a zero-copy read of an array of structs from a VMO must do their own unsafe.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
James (S), you're an OWNER for a bunch of this code - could you give that a regular code review?
Code-Review | +2 |
LGTM for //src/storage
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
/// Provides the thinnest wrapper possible over `zx_vmo_read`.
is this still true?
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Commit-Queue | +1 |
Fuchsia-Auto-Submit | +1 |
/// Provides the thinnest wrapper possible over `zx_vmo_read`.
Adam Perryis this still true?
It's very close to true but I'll rephrase.
Done
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
James Sullivanwhat's the motivation here? is this tied to a bug? is it tied to a Rust requirement? is it tied to bug-prone patterns?
https://fxrev.dev/1361058 is a bit of background.
We already have `Vmo::read_to_array`, but it requires size to be a constant. I was going to add `read_to_boxed_slice`, and Adam suggested we do this instead.
It's nice to encapsulate unsafe code in a well-vetted library like this, which is one argument for this change. Otherwise, clients who wish to do a zero-copy read of an array of structs from a VMO must do their own unsafe.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
4 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: sdk/rust/zx/src/vmo.rs
Insertions: 1, Deletions: 1.
The diff is too large to show. Please review the diff.
```
[zx][rs] Align all VMO read calls to use FromBytes.
u8 already satisfies this trait so this is strictly more general.
This change does require adding some turbofishes in places where
Rust's type inference can no longer unambiguously pick a type.
Leaves the Vmo::read() call still using raw bytes to avoid needing
to call drop_in_place when we don't know if the call will succeed.
Requires callers to use `T: Copy` to avoid footguns about missed
`Drop` calls. Seems like all of the current callers of higher level
methods like read_to_vec are fine with this bound. We can always
revisit if we find it difficult to use in practice.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Change has been successfully rolled: https://turquoise-internal-review.googlesource.com/1047794
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |