Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use KnownLayout to construct and operate on Refs #678

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

joshlf
Copy link
Member

@joshlf joshlf commented Dec 6, 2023

Add Ref::new_known_layout_name_to_be_bikeshedded. This is a private constructor which takes a T: ?Sized + KnownLayout bound. Before we make KnownLayout public, we will make it public and settle on a final name.

Also add the ability to dereference a Ref, requiring the caller to promise bit validity. Refactor TryFromBytes::try_from_ref to use this instead of calling Ptr::as_ref directly, allowing try_from_ref's internal safety comments to be significantly simpler. This machinery can be re-used to add APIs with a T: ?Sized + KnownLayout + FromBytes bound which allow for safe dereferencing.

Makes progress on #29

Add `Ref::new_known_layout_name_to_be_bikeshedded`. This is a private
constructor which takes a `T: ?Sized + KnownLayout` bound. Before we
make `KnownLayout` public, we will make it public and settle on a final
name.

Also add the ability to dereference a `Ref`, requiring the caller to
promise bit validity. Refactor `TryFromBytes::try_from_ref` to use this
instead of calling `Ptr::as_ref` directly, allowing `try_from_ref`'s
internal safety comments to be significantly simpler. This machinery can
be re-used to add APIs with a `T: ?Sized + KnownLayout + FromBytes`
bound which allow for safe dereferencing.

Makes progress on #29
@joshlf joshlf requested a review from jswrenn December 6, 2023 02:08
@joshlf joshlf mentioned this pull request Dec 6, 2023
34 tasks
@joshlf joshlf added this pull request to the merge queue Dec 7, 2023
Merged via the queue into main with commit ff58bf6 Dec 7, 2023
126 checks passed
@joshlf joshlf deleted the known-layout-ref-constructor branch December 7, 2023 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants