fn try_send_queued(&mut self, cx: &mut Context<'_>) -> Result<(), zx::Status> {
        while !self.buffer.is_empty() {
            let cursor = self.buffer_cursor;
            match Pin::new(&mut self.channel).poll_write(cx, &self.buffer[cursor..]) {
                Poll::Pending => {
                    // Unable to write, try again later.
                    return Ok(());
                }
                Poll::Ready(Err(e)) => {
                    warn!("Error writing bytes to channel: {:?}", e);
                    return Err(e.into());
                }
                Poll::Ready(Ok(written)) => {
                    self.buffer_cursor = cursor + written;

                    // If we've finished writing the entire buffer, we are ready to flush.
                    if self.buffer_cursor >= self.buffer.len() {
                        // Reset the pointer to the front of the buffer as we've finished writing.
                        self.buffer = Vec::new();
                        self.buffer_cursor = 0;
                        self.needs_flush = true;
                    }
                }
            }
        }

        // Attempt to flush
        if self.needs_flush {
            match Pin::new(&mut self.channel).poll_flush(cx) {
                Poll::Ready(Ok(())) => self.needs_flush = false,
                Poll::Ready(Err(e)) => return Err(e.into()),
                Poll::Pending => (),
            }
        }
        Ok(())
    }
/// Attempts to send any queued data to the `channel`.
/// Returns Error if writing to or flushing the channel fails, OK otherwise.
Attempts to send any queued data to the `channel`.
Returns Error if writing to or flushing the channel fails, OK otherwise.
Attempts to send any queued data to the ` channel ` . Returns Error if writing to or flushing the channel fails OK otherwise .
fn try_send_queued(&mut self, cx: &mut Context<'_>) -> Result<(), zx::Status> {
        while !self.buffer.is_empty() {
            let cursor = self.buffer_cursor;
            match Pin::new(&mut self.channel).poll_write(cx, &self.buffer[cursor..]) {
                Poll::Pending => {
                    // Unable to write, try again later.
                    return Ok(());
                }
                Poll::Ready(Err(e)) => {
                    warn!("Error writing bytes to channel: {:?}", e);
                    return Err(e.into());
                }
                Poll::Ready(Ok(written)) => {
                    self.buffer_cursor = cursor + written;
                    // If we've finished writing the entire buffer, we are ready to flush.
                    if self.buffer_cursor >= self.buffer.len() {
                        // Reset the pointer to the front of the buffer as we've finished writing.
                        self.buffer = Vec::new();
                        self.buffer_cursor = 0;
                        self.needs_flush = true;
                    }
                }
            }
        }
        // Attempt to flush
        if self.needs_flush {
            match Pin::new(&mut self.channel).poll_flush(cx) {
                Poll::Ready(Ok(())) => self.needs_flush = false,
                Poll::Ready(Err(e)) => return Err(e.into()),
                Poll::Pending => (),
            }
        }
        Ok(())
    }
fn try_send_queued ( & mut self , cx : & mut Context < ' _ > ) -> Result < ( ) , zx :: Status > { while ! self . buffer . is_empty ( ) { let cursor = self . buffer_cursor ; match Pin :: new ( & mut self . channel ) . poll_write ( cx , & self . buffer [ cursor .. ] ) { Poll :: Pending => { // Unable to write, try again later. return Ok ( ( ) ) ; } Poll :: Ready ( Err ( e ) ) => { warn ! ( " " e ) ; return Err ( e . into ( ) ) ; } Poll :: Ready ( Ok ( written ) ) => { self . buffer_cursor = cursor + written ; // If we've finished writing the entire buffer, we are ready to flush. if self . buffer_cursor >= self . buffer . len ( ) { // Reset the pointer to the front of the buffer as we've finished writing. self . buffer = Vec :: new ( ) ; self . buffer_cursor = 0 ; self . needs_flush = true ; } } } } // Attempt to flush if self . needs_flush { match Pin :: new ( & mut self . channel ) . poll_flush ( cx ) { Poll :: Ready ( Ok ( ( ) ) ) => self . needs_flush = false , Poll :: Ready ( Err ( e ) ) => return Err ( e . into ( ) ) , Poll :: Pending => ( ) , } } Ok ( ( ) ) }
Attempts to send any queued data to the `channel`.
Attempts to send any queued data to the ` channel ` .
&mut self
cx
&mut Context<'_>
&mut self
cx
&mut Context<'_>