From c0b49c9052450a13d0c85538e8f36095106bd0f4 Mon Sep 17 00:00:00 2001 From: james58899 Date: Wed, 21 Feb 2024 19:49:23 +0000 Subject: [PATCH] Add peek --- src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index b4e2011..b016573 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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> { + 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 { + 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(