pub(crate) async fn peek(&self, buf: &mut [u8]) -> io::Result<usize> {
        let source = self.reactor.upgrade().unwrap().recv(
            self.stream.as_raw_fd(),
            buf.len(),
            MsgFlags::MSG_PEEK,
        );

        let sz = source.collect_rw().await?;
        match source.extract_source_type() {
            SourceType::SockRecv(mut src) => {
                buf[0..sz].copy_from_slice(&src.take().unwrap().as_bytes()[0..sz]);
            }
            _ => unreachable!(),
        }
        Ok(sz)
    }
/// Receives data on the socket from the remote address to which it is
/// connected, without removing that data from the queue.
///
/// On success, returns the number of bytes peeked.
/// Successive calls return the same data. This is accomplished by passing
/// `MSG_PEEK` as a flag to the underlying `recv` system call.
Receives data on the socket from the remote address to which it is
connected, without removing that data from the queue.

On success, returns the number of bytes peeked.
Successive calls return the same data. This is accomplished by passing
`MSG_PEEK` as a flag to the underlying `recv` system call.
Receives data on the socket from the remote address to which it is connected without removing that data from the queue . On success returns the number of bytes peeked . Successive calls return the same data . This is accomplished by passing ` MSG_PEEK ` as a flag to the underlying ` recv ` system call .
pub(crate) async fn peek(&self, buf: &mut [u8]) -> io::Result<usize> {
        let source = self.reactor.upgrade().unwrap().recv(
            self.stream.as_raw_fd(),
            buf.len(),
            MsgFlags::MSG_PEEK,
        );
        let sz = source.collect_rw().await?;
        match source.extract_source_type() {
            SourceType::SockRecv(mut src) => {
                buf[0..sz].copy_from_slice(&src.take().unwrap().as_bytes()[0..sz]);
            }
            _ => unreachable!(),
        }
        Ok(sz)
    }
pub ( crate ) async fn peek ( & self , buf : & mut [ u8 ] ) -> io :: Result < usize > { let source = self . reactor . upgrade ( ) . unwrap ( ) . recv ( self . stream . as_raw_fd ( ) , buf . len ( ) , MsgFlags :: MSG_PEEK , ) ; let sz = source . collect_rw ( ) . await ? ; match source . extract_source_type ( ) { SourceType :: SockRecv ( mut src ) => { buf [ 0 .. sz ] . copy_from_slice ( & src . take ( ) . unwrap ( ) . as_bytes ( ) [ 0 .. sz ] ) ; } _ => unreachable ! ( ) , } Ok ( sz ) }
Receives data on the socket from the remote address to which it is
connected, without removing that data from the queue.
Receives data on the socket from the remote address to which it is connected without removing that data from the queue .
&self
buf
&mut [u8]
&self
buf
&mut [u8]