-
Notifications
You must be signed in to change notification settings - Fork 14k
Open
Labels
A-ioArea: `std::io`, `std::fs`, `std::net` and `std::path`Area: `std::io`, `std::fs`, `std::net` and `std::path`T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.
Description
cc #78485
ReadBuf is unstable, part of the read-buf feature. I believe the API might be improved by some of the following ways (I've grouped methods by theme):
Construction
- remove
new(it should create an emptyReadBuf, but that is useless, I think) - Should implement
From<&'a mut [u8]> for ReadBuf<'a>to create a ReadBuf from a byte slice (rather thannew) - Should implement
From<&'a mut [MaybeUninit<u8>]> for ReadBuf<'a>to create a ReadBuf from a byte slice (rather thanuninit)
Length functions
- Keep
capacity filled_len->lento matchVecetc.- remove
filled_len(usefilled().len()) - remove
remaining(can usecapacity() - len()orunfilled().len()) - remove
initialized_len(can useinitialized().len())
Slicing functions
- Keep
filled,initialized,unfilled,uninitialized, and mut variants Removefilledandfilled_mut, replace by implementingInto<&'a mut [u8]> for ReadBuf<'a>
Initializing data
- Remove
initialize_unfilledandinitialize_unfilled_to, unless these are super useful- rationale, getting unfilled slice is easy, initialising is easy, so it seems the only benefit is tracking this
- keep
assume_init
Misc
- Keep
clearandappend - Remove
add_filled - Rename
set_filledtoassume_filled(to matchassume_init)
The current API is documented at https://doc.rust-lang.org/nightly/std/io/struct.ReadBuf.html
This issue continues a discussion from Zulip (https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/ReadBuf.20API), there was not much discussion relevant to the points above.
liigo
Metadata
Metadata
Assignees
Labels
A-ioArea: `std::io`, `std::fs`, `std::net` and `std::path`Area: `std::io`, `std::fs`, `std::net` and `std::path`T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.