bytes
bytes copied to clipboard
Add SeekBuf trait and BufCursor implementation
Fixes #657.
This PR introduces the SeekBuf
trait for buffers that support arbitrary lookups of memory, and a new BufCursor
struct for immutably iterating over a SeekBuf
type.
SeekBuf
is strictly an opt-in trait with additional functionality over the standard Buf
trait and otherwise does not change the API of this crate.
The BufCursor
type provides compatibility to a wide range of core/std Rust features through its Iterator
implementation. It also allows recursive and non-consuming access to the full memory of a buffer that was otherwise not possible via the Buf
trait.