fn read(&mut self, data: &mut [u8]) -> Result<usize, ReadError> {
        // Abort the request if it has been canceled.
        if self.shared.future_dropped.load() {
            return Err(ReadError::Abort);
        }

        // Create a task context using a waker provided by the agent so we can
        // do an asynchronous read.
        if let Some(waker) = self.request_body_waker.as_ref() {
            let mut context = Context::from_waker(waker);

            match Pin::new(&mut self.request_body).poll_read(&mut context, data) {
                Poll::Pending => Err(ReadError::Pause),
                Poll::Ready(Ok(len)) => Ok(len),
                Poll::Ready(Err(e)) => {
                    log::error!("error reading request body: {}", e);
                    Err(ReadError::Abort)
                }
            }
        } else {
            // The request should never be started without calling init first.
            log::error!("request has not been initialized!");
            Err(ReadError::Abort)
        }
    }
/// Gets called by curl when attempting to send bytes of the request body.
Gets called by curl when attempting to send bytes of the request body.
Gets called by curl when attempting to send bytes of the request body .
fn read(&mut self, data: &mut [u8]) -> Result<usize, ReadError> {
        // Abort the request if it has been canceled.
        if self.shared.future_dropped.load() {
            return Err(ReadError::Abort);
        }
        // Create a task context using a waker provided by the agent so we can
        // do an asynchronous read.
        if let Some(waker) = self.request_body_waker.as_ref() {
            let mut context = Context::from_waker(waker);
            match Pin::new(&mut self.request_body).poll_read(&mut context, data) {
                Poll::Pending => Err(ReadError::Pause),
                Poll::Ready(Ok(len)) => Ok(len),
                Poll::Ready(Err(e)) => {
                    log::error!("error reading request body: {}", e);
                    Err(ReadError::Abort)
                }
            }
        } else {
            // The request should never be started without calling init first.
            log::error!("request has not been initialized!");
            Err(ReadError::Abort)
        }
    }
fn read ( & mut self , data : & mut [ u8 ] ) -> Result < usize , ReadError > { // Abort the request if it has been canceled. if self . shared . future_dropped . load ( ) { return Err ( ReadError :: Abort ) ; } // Create a task context using a waker provided by the agent so we can // do an asynchronous read. if let Some ( waker ) = self . request_body_waker . as_ref ( ) { let mut context = Context :: from_waker ( waker ) ; match Pin :: new ( & mut self . request_body ) . poll_read ( & mut context , data ) { Poll :: Pending => Err ( ReadError :: Pause ) , Poll :: Ready ( Ok ( len ) ) => Ok ( len ) , Poll :: Ready ( Err ( e ) ) => { log :: error ! ( " " e ) ; Err ( ReadError :: Abort ) } } } else { // The request should never be started without calling init first. log :: error ! ( " " ) ; Err ( ReadError :: Abort ) } }
Gets called by curl when attempting to send bytes of the request body.
Gets called by curl when attempting to send bytes of the request body .
&mut self
data
&mut [u8]