Add SeekBuf trait and BufCursor implementation#658
Add SeekBuf trait and BufCursor implementation#658dylanplecki wants to merge 10 commits intotokio-rs:masterfrom
Conversation
…, remove default pinned impls, and fix some new failing test cases from bugs
…g in cursor chunk_to impl
|
I'm really sorry that I didn't get around to responding to this when you posted your other feature requests. It's pretty normal to do something like this by taking a You're adding a lot of complex code using indexes in your |
|
@Darksonn no worries! Thanks for the feedback. This change intends to provide additional functionality for library code that accepts a For example, let's say that I have a method that accepts something along the lines of an As the library maintainer, we have no guarantee how cheap the Since buffers may also be non-contiguous, adding bounds like Outside of I definitely understand that this library is primarily used by Tokio and is provided as a utility with no guarantees that anything beyond the scope of Tokio will be implemented. I also agree that the implementation is quite complex beyond the guarantees of the Rust compiler (this is hopefully well-covered by the added unit tests), so will add a maintenance burden to the project. For my use case, I've settled on maintaining a small fork of this library with the additional functionality that may not be useful for Tokio or other core use-cases of the If you think that there isn't much utility in adding this functionality to this crate, or would prefer not to maintain this code long-term, I would be happy to close this as "won't fix" and retain the scope of my usage to my fork. Thanks again for the review! |
Fixes #657.
This PR introduces the
SeekBuftrait for buffers that support arbitrary lookups of memory, and a newBufCursorstruct for immutably iterating over aSeekBuftype.SeekBufis strictly an opt-in trait with additional functionality over the standardBuftrait and otherwise does not change the API of this crate.The
BufCursortype provides compatibility to a wide range of core/std Rust features through itsIteratorimplementation. It also allows recursive and non-consuming access to the full memory of a buffer that was otherwise not possible via theBuftrait.