MCPcopy Create free account
hub / github.com/erans/pgsqlite / poll_read

Method poll_read

src/main.rs:682–697  ·  view source on GitHub ↗
(
        mut self: Pin<&mut Self>,
        cx: &mut Context<'_>,
        buf: &mut ReadBuf<'_>,
    )

Source from the content-addressed store, hash-verified

680
681impl<S: AsyncRead + Unpin> AsyncRead for StreamWithBuffer<S> {
682 fn poll_read(
683 mut self: Pin<&mut Self>,
684 cx: &mut Context<'_>,
685 buf: &mut ReadBuf<'_>,
686 ) -> Poll<std::io::Result<()>> {
687 // First, drain any buffered data
688 if !self.buffer.is_empty() {
689 let len = std::cmp::min(buf.remaining(), self.buffer.len());
690 buf.put_slice(&self.buffer[..len]);
691 self.buffer.advance(len);
692 return Poll::Ready(Ok(()));
693 }
694
695 // Then read from the underlying stream
696 Pin::new(&mut self.stream).poll_read(cx, buf)
697 }
698}
699
700impl<S: AsyncWrite + Unpin> AsyncWrite for StreamWithBuffer<S> {

Callers

nothing calls this directly

Calls 3

remainingMethod · 0.80
is_emptyMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected