impl<T> AsyncRead for Rewind<T> where
T: AsyncRead + Unpin,
{ fn poll_read( mutself: Pin<&mutSelf>,
cx: &mut task::Context<'_>,
buf: &mut ReadBuf<'_>,
) -> Poll<io::Result<()>> { iflet Some(mut prefix) = self.pre.take() { // If there are no remaining bytes, let the bytes get dropped. if !prefix.is_empty() { let copy_len = cmp::min(prefix.len(), buf.remaining()); // TODO: There should be a way to do following two lines cleaner...
buf.put_slice(&prefix[..copy_len]);
prefix.advance(copy_len); // Put back what's left if !prefix.is_empty() { self.pre = Some(prefix);
}
#[cfg(test)] mod tests { // FIXME: re-implement tests with `async/await`, this import should // trigger a warning to remind us usesuper::Rewind; use bytes::Bytes; use tokio::io::AsyncReadExt;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.