Skip to content

Commit

Permalink
Merge pull request #49 from james58899/add-peek
Browse files Browse the repository at this point in the history
Add peek
  • Loading branch information
sfackler authored Feb 24, 2024
2 parents ee179d7 + c0b49c9 commit 01d32fa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,20 @@ where
future::poll_fn(|cx| self.as_mut().poll_do_handshake(cx)).await
}

/// Like [`SslStream::ssl_peek`](ssl::SslStream::ssl_peek).
pub fn poll_peek(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<Result<usize, ssl::Error>> {
self.with_context(cx, |s| cvt_ossl(s.ssl_peek(buf)))
}

/// A convenience method wrapping [`poll_peek`](Self::poll_peek).
pub async fn peek(mut self: Pin<&mut Self>, buf: &mut [u8]) -> Result<usize, ssl::Error> {
future::poll_fn(|cx| self.as_mut().poll_peek(cx, buf)).await
}

/// Like [`SslStream::read_early_data`](ssl::SslStream::read_early_data).
#[cfg(ossl111)]
pub fn poll_read_early_data(
Expand Down

0 comments on commit 01d32fa

Please sign in to comment.