-
Notifications
You must be signed in to change notification settings - Fork 55
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
Make ReservedSpace
more flexible
#254
Milestone
Comments
Thank you for this issue. It also summarizes some of my previous ideas. I wanted to only expose a |
Merged
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The only way to use
ReservedSpace
currently is to use thestd::io::Write
implementation. However, this assumes that the entire value can be written in one go. This prevents certain patterns, such as having a header in the value which contains the a checksum of the remaining bytes.There should be some mechanism to reference arbitrary bytes within the space. Some options (naming TBD):
fn written_bytes_mut(&mut self) -> &mut [u8]
. This is safe as the bytes are known to be initialized.fn zero_bytes_mut(&mut self) -> &mut [u8]
. This would mark the entire space as written.fn as_bytes_mut_uninit(&mut self) -> &mut [MaybeUninit<u8>]
. Can be used to write arbitrary data in any order. Needs a complementary method to mark them as written:unsafe fn assume_written(&mut self, count: usize)
, which isunsafe
because caller must guarantee that all bytes0..count
have been initialized.The text was updated successfully, but these errors were encountered: