fn write(&mut self, data: &[u8]) -> Result<usize, curl::easy::WriteError> {
        trace!("received {} bytes of data", data.len());

        if self.state.is_closed() {
            debug!("aborting write, request is already closed");
            return Ok(0);
        }

        let mut buffer = self.state.buffer.lock().unwrap();

        // If there is existing data in the buffer, pause the request until the existing data is consumed.
        if !buffer.is_empty() {
            trace!("response buffer is not empty, pausing transfer");
            return Err(curl::easy::WriteError::Pause);
        }

        // Store the data in the buffer.
        *buffer = Bytes::from(data);

        // Notify the reader.
        self.state.read_waker.wake();

        Ok(buffer.len())
    }
// Gets called by curl when bytes from the response body are received.
Gets called by curl when bytes from the response body are received.
Gets called by curl when bytes from the response body are received .
fn write(&mut self, data: &[u8]) -> Result<usize, curl::easy::WriteError> {
        trace!("received {} bytes of data", data.len());
        if self.state.is_closed() {
            debug!("aborting write, request is already closed");
            return Ok(0);
        }
        let mut buffer = self.state.buffer.lock().unwrap();
        // If there is existing data in the buffer, pause the request until the existing data is consumed.
        if !buffer.is_empty() {
            trace!("response buffer is not empty, pausing transfer");
            return Err(curl::easy::WriteError::Pause);
        }
        // Store the data in the buffer.
        *buffer = Bytes::from(data);
        // Notify the reader.
        self.state.read_waker.wake();
        Ok(buffer.len())
    }
fn write ( & mut self , data : & [ u8 ] ) -> Result < usize , curl :: easy :: WriteError > { trace ! ( " " data len ( ) ) ; if self . state . is_closed ( ) { debug ! ( " " ) ; return Ok ( 0 ) ; } let mut buffer = self . state . buffer . lock ( ) . unwrap ( ) ; // If there is existing data in the buffer, pause the request until the existing data is consumed. if ! buffer . is_empty ( ) { trace ! ( " " ) ; return Err ( curl :: easy :: WriteError :: Pause ) ; } // Store the data in the buffer. * buffer = Bytes :: from ( data ) ; // Notify the reader. self . state . read_waker . wake ( ) ; Ok ( buffer . len ( ) ) }
Gets called by curl when bytes from the response body are received.
Gets called by curl when bytes from the response body are received .
&mut self
data
&[u8]
&mut self
data
&[u8]