fn poll_read_generic<T, U>(
        &mut self,
        cx: &mut Context,
        ordered: bool,
        mut read_fn: T,
    ) -> Poll<Result<Option<U>, ReadError>>
    where
        T: FnMut(&mut Chunks) -> ReadStatus<U>,
    {
        use proto::ReadError::*;
        if self.all_data_read {
            return Poll::Ready(Ok(None));
        }

        let mut conn = self.conn.lock("RecvStream::poll_read");
        if self.is_0rtt {
            conn.check_0rtt().map_err(|()| ReadError::ZeroRttRejected)?;
        }

        // If we stored an error during a previous call, return it now. This can happen if a
        // `read_fn` both wants to return data and also returns an error in its final stream status.
        let status = match self.reset.take() {
            Some(code) => ReadStatus::Failed(None, Reset(code)),
            None => {
                let mut recv = conn.inner.recv_stream(self.stream);
                let mut chunks = recv.read(ordered)?;
                let status = read_fn(&mut chunks);
                if chunks.finalize().should_transmit() {
                    conn.wake();
                }
                status
            }
        };

        match status {
            ReadStatus::Readable(read) => Poll::Ready(Ok(Some(read))),
            ReadStatus::Finished(read) => {
                self.all_data_read = true;
                Poll::Ready(Ok(read))
            }
            ReadStatus::Failed(read, Blocked) => match read {
                Some(val) => Poll::Ready(Ok(Some(val))),
                None => {
                    if let Some(ref x) = conn.error {
                        return Poll::Ready(Err(ReadError::ConnectionClosed(x.clone())));
                    }
                    conn.blocked_readers.insert(self.stream, cx.waker().clone());
                    Poll::Pending
                }
            },
            ReadStatus::Failed(read, Reset(error_code)) => match read {
                None => {
                    self.all_data_read = true;
                    Poll::Ready(Err(ReadError::Reset(error_code)))
                }
                done => {
                    self.reset = Some(error_code);
                    Poll::Ready(Ok(done))
                }
            },
        }
    }
/// Handle common logic related to reading out of a receive stream
///
/// This takes an `FnMut` closure that takes care of the actual reading process, matching
/// the detailed read semantics for the calling function with a particular return type.
/// The closure can read from the passed `&mut Chunks` and has to return the status after
/// reading: the amount of data read, and the status after the final read call.
Handle common logic related to reading out of a receive stream
This takes an `FnMut` closure that takes care of the actual reading process, matching
the detailed read semantics for the calling function with a particular return type.
The closure can read from the passed `&mut Chunks` and has to return the status after
reading: the amount of data read, and the status after the final read call.
Handle common logic related to reading out of a receive stream This takes an ` FnMut ` closure that takes care of the actual reading process matching the detailed read semantics for the calling function with a particular return type . The closure can read from the passed ` &mut Chunks ` and has to return the status after reading : the amount of data read and the status after the final read call .
fn poll_read_generic<T, U>(
        &mut self,
        cx: &mut Context,
        ordered: bool,
        mut read_fn: T,
    ) -> Poll<Result<Option<U>, ReadError>>
    where
        T: FnMut(&mut Chunks) -> ReadStatus<U>,
    {
        use proto::ReadError::*;
        if self.all_data_read {
            return Poll::Ready(Ok(None));
        }
        let mut conn = self.conn.lock("RecvStream::poll_read");
        if self.is_0rtt {
            conn.check_0rtt().map_err(|()| ReadError::ZeroRttRejected)?;
        }
        // If we stored an error during a previous call, return it now. This can happen if a
        // `read_fn` both wants to return data and also returns an error in its final stream status.
        let status = match self.reset.take() {
            Some(code) => ReadStatus::Failed(None, Reset(code)),
            None => {
                let mut recv = conn.inner.recv_stream(self.stream);
                let mut chunks = recv.read(ordered)?;
                let status = read_fn(&mut chunks);
                if chunks.finalize().should_transmit() {
                    conn.wake();
                }
                status
            }
        };
        match status {
            ReadStatus::Readable(read) => Poll::Ready(Ok(Some(read))),
            ReadStatus::Finished(read) => {
                self.all_data_read = true;
                Poll::Ready(Ok(read))
            }
            ReadStatus::Failed(read, Blocked) => match read {
                Some(val) => Poll::Ready(Ok(Some(val))),
                None => {
                    if let Some(ref x) = conn.error {
                        return Poll::Ready(Err(ReadError::ConnectionClosed(x.clone())));
                    }
                    conn.blocked_readers.insert(self.stream, cx.waker().clone());
                    Poll::Pending
                }
            },
            ReadStatus::Failed(read, Reset(error_code)) => match read {
                None => {
                    self.all_data_read = true;
                    Poll::Ready(Err(ReadError::Reset(error_code)))
                }
                done => {
                    self.reset = Some(error_code);
                    Poll::Ready(Ok(done))
                }
            },
        }
    }
fn poll_read_generic < T , U > ( & mut self , cx : & mut Context , ordered : bool , mut read_fn : T , ) -> Poll < Result < Option < U > , ReadError > > where T : FnMut ( & mut Chunks ) -> ReadStatus < U > , { use proto :: ReadError :: * ; if self . all_data_read { return Poll :: Ready ( Ok ( None ) ) ; } let mut conn = self . conn . lock ( " " ) ; if self . is_0rtt { conn . check_0rtt ( ) . map_err ( | ( ) | ReadError :: ZeroRttRejected ) ? ; } // If we stored an error during a previous call, return it now. This can happen if a // `read_fn` both wants to return data and also returns an error in its final stream status. let status = match self . reset . take ( ) { Some ( code ) => ReadStatus :: Failed ( None , Reset ( code ) ) , None => { let mut recv = conn . inner . recv_stream ( self . stream ) ; let mut chunks = recv . read ( ordered ) ? ; let status = read_fn ( & mut chunks ) ; if chunks . finalize ( ) . should_transmit ( ) { conn . wake ( ) ; } status } } ; match status { ReadStatus :: Readable ( read ) => Poll :: Ready ( Ok ( Some ( read ) ) ) , ReadStatus :: Finished ( read ) => { self . all_data_read = true ; Poll :: Ready ( Ok ( read ) ) } ReadStatus :: Failed ( read , Blocked ) => match read { Some ( val ) => Poll :: Ready ( Ok ( Some ( val ) ) ) , None => { if let Some ( ref x ) = conn . error { return Poll :: Ready ( Err ( ReadError :: ConnectionClosed ( x . clone ( ) ) ) ) ; } conn . blocked_readers . insert ( self . stream , cx . waker ( ) . clone ( ) ) ; Poll :: Pending } } , ReadStatus :: Failed ( read , Reset ( error_code ) ) => match read { None => { self . all_data_read = true ; Poll :: Ready ( Err ( ReadError :: Reset ( error_code ) ) ) } done => { self . reset = Some ( error_code ) ; Poll :: Ready ( Ok ( done ) ) } } , } }
Handle common logic related to reading out of a receive stream
This takes an `FnMut` closure that takes care of the actual reading process, matching
the detailed read semantics for the calling function with a particular return type.
Handle common logic related to reading out of a receive stream This takes an ` FnMut ` closure that takes care of the actual reading process matching the detailed read semantics for the calling function with a particular return type .
&mut self
cx
&mut Context
ordered
bool
read_fn
T
&mut self
cx
&mut Context
ordered
bool
read_fn
T