pub struct BufferCursor { /* private fields */ }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§
Source§impl BufferCursor
impl BufferCursor
Sourcepub fn new(buf: &[u8]) -> BufferCursor
pub fn new(buf: &[u8]) -> BufferCursor
Instantiate a new cursor over the beginning of the provided buf.
Sourcepub fn with_len(len: usize) -> BufferCursor
pub fn with_len(len: usize) -> BufferCursor
Instantiate a new cursor representing the beginning of a buffer
with a specified len.
Sourcepub fn is_pending(&self) -> bool
pub fn is_pending(&self) -> bool
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,
Sourcepub 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>
Sourcepub fn read_remaining<R>(
&mut self,
reader: &mut R,
data: &mut [u8],
cx: &mut Context<'_>,
) -> PollDecodeStatus<(), Error>
pub fn read_remaining<R>( &mut self, reader: &mut R, data: &mut [u8], cx: &mut Context<'_>, ) -> PollDecodeStatus<(), Error>
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.
Sourcepub fn fill_vec<R>(
&mut self,
reader: &mut R,
data: &mut Vec<u8>,
cx: &mut Context<'_>,
) -> PollDecodeStatus<(), Error>where
R: AsyncBufRead + Unpin,
pub fn fill_vec<R>(
&mut self,
reader: &mut R,
data: &mut Vec<u8>,
cx: &mut Context<'_>,
) -> PollDecodeStatus<(), Error>where
R: AsyncBufRead + Unpin,
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.