Skip to content

Commit

Permalink
Add peek
Browse files Browse the repository at this point in the history
  • Loading branch information
james58899 committed Feb 21, 2024
1 parent ee179d7 commit c0b49c9
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 c0b49c9

Please sign in to comment.