pub fn poll_datagram(
            &self,
            cx: &mut Context<'_>,
            out: &mut Vec<u8>,
        ) -> Poll<Result<usize, zx_status::Status>> {
            let avail = self.socket.outstanding_read_bytes()?;
            let len = out.len();
            out.resize(len + avail, 0);
            let (_, mut tail) = out.split_at_mut(len);
            match self.socket.read(&mut tail) {
                Err(zx_status::Status::SHOULD_WAIT) => {
                    self.waker.sched(cx);
                    Poll::Pending
                }
                Err(e) => Poll::Ready(Err(e)),
                Ok(bytes) => {
                    if bytes == avail {
                        Poll::Ready(Ok(bytes))
                    } else {
                        Poll::Ready(Err(zx_status::Status::BAD_STATE))
                    }
                }
            }
        }
/// Polls for the next data on the socket, appending it to the end of |out| if it has arrived.
/// Not very useful for a non-datagram socket as it will return all available data
/// on the socket.
Polls for the next data on the socket, appending it to the end of |out| if it has arrived.
Not very useful for a non-datagram socket as it will return all available data
on the socket.
Polls for the next data on the socket appending it to the end of |out| if it has arrived . Not very useful for a non - datagram socket as it will return all available data on the socket .
pub fn poll_datagram(
            &self,
            cx: &mut Context<'_>,
            out: &mut Vec<u8>,
        ) -> Poll<Result<usize, zx_status::Status>> {
            let avail = self.socket.outstanding_read_bytes()?;
            let len = out.len();
            out.resize(len + avail, 0);
            let (_, mut tail) = out.split_at_mut(len);
            match self.socket.read(&mut tail) {
                Err(zx_status::Status::SHOULD_WAIT) => {
                    self.waker.sched(cx);
                    Poll::Pending
                }
                Err(e) => Poll::Ready(Err(e)),
                Ok(bytes) => {
                    if bytes == avail {
                        Poll::Ready(Ok(bytes))
                    } else {
                        Poll::Ready(Err(zx_status::Status::BAD_STATE))
                    }
                }
            }
        }
pub fn poll_datagram ( & self , cx : & mut Context < ' _ > , out : & mut Vec < u8 > , ) -> Poll < Result < usize , zx_status :: Status > > { let avail = self . socket . outstanding_read_bytes ( ) ? ; let len = out . len ( ) ; out . resize ( len + avail , 0 ) ; let ( _ , mut tail ) = out . split_at_mut ( len ) ; match self . socket . read ( & mut tail ) { Err ( zx_status :: Status :: SHOULD_WAIT ) => { self . waker . sched ( cx ) ; Poll :: Pending } Err ( e ) => Poll :: Ready ( Err ( e ) ) , Ok ( bytes ) => { if bytes == avail { Poll :: Ready ( Ok ( bytes ) ) } else { Poll :: Ready ( Err ( zx_status :: Status :: BAD_STATE ) ) } } } }
Polls for the next data on the socket, appending it to the end of |out| if it has arrived.
Polls for the next data on the socket appending it to the end of |out| if it has arrived .
&self
cx
&mut Context<'_>
out
&mut Vec<u8>
&self
cx
&mut Context<'_>
out
&mut Vec<u8>