Struct diny::buffer::BufferCursor [−][src]
pub struct BufferCursor { /* fields omitted */ }
Expand description
Retains the current index state into a serialization buffer.
Typically used by a BufferState to keep track of which bytes still require processing.
Implementations
Instantiate a new cursor over the beginning of the provided buf
.
Instantiate a new cursor representing the beginning of a buffer
with a specified len
.
Return whether or not more data is expected to be processed.
pub fn start_write<W>(
&mut self,
writer: &mut W,
data: &[u8],
cx: &mut Context<'_>
) -> PollEncodeStatus<Error> where
W: AsyncWrite + Unpin,
pub fn write_remaining<W>(
&mut self,
writer: &mut W,
data: &[u8],
cx: &mut Context<'_>
) -> PollEncodeStatus<Error> where
W: AsyncWrite + Unpin,
pub fn write_remaining<W>(
&mut self,
writer: &mut W,
data: &[u8],
cx: &mut Context<'_>
) -> PollEncodeStatus<Error> where
W: AsyncWrite + Unpin,
Attempt to write all of the bytes in data
, starting from the current
offset of the cursor.
This implementation differs from a typical AsyncWrite operation in that the contents of data are expected to be unchanging from one call to the next, despite progress being made. The expectation is that the caller does not need to retain any information about the progress of the write, and simply needs to pass in the same references for each call.
pub fn start_read<R>(
&mut self,
reader: &mut R,
data: &mut [u8],
cx: &mut Context<'_>
) -> PollDecodeStatus<(), Error> where
R: AsyncRead + Unpin,
Attempt to read all remaining bytes that are expected into data
, starting
from the current offset of the cursor.
This implementation differs from a typical AsyncRead operation in that the contents of data are expected to be unchanging from one call to the next, despite progress being made. The expectation is that the caller does not need to retain any information about the progress of the read, and simply needs to pass in the same references for each call.
pub fn fill_vec<R>(
&mut self,
reader: &mut R,
data: &mut Vec<u8, Global>,
cx: &mut Context<'_>
) -> PollDecodeStatus<(), Error> where
R: AsyncBufRead + Unpin,
This is supported on crate features std
or alloc
only.
pub fn fill_vec<R>(
&mut self,
reader: &mut R,
data: &mut Vec<u8, Global>,
cx: &mut Context<'_>
) -> PollDecodeStatus<(), Error> where
R: AsyncBufRead + Unpin,
std
or alloc
only.Semantically equivalent to read_remaining
, only this method takes advantage
of the AsyncBufRead trait to minimize the number of copies required to transfer
the bytes into a pre-allocated Vec.