pub async fn write(&mut self, data: &[u8]) -> Result<usize, Error> {
        if self.task.is_terminated() {
            return Err(Error::Shutdown);
        }

        let shared = &self.shared;
        let mut shared_lock_future = shared.lock();
        let mut write_done =
            future::poll_fn(|cx| match Pin::new(&mut shared_lock_future).poll(cx) {
                Poll::Ready(mut shared_guard) => {
                    let len = shared_guard.send_window.write(data);
                    if len > 0 {
                        Poll::Ready(len)
                    } else {
                        shared_guard.write_ready = Some(cx.waker().clone());
                        if let Some(send_ready) = shared_guard.send_ready.take() {
                            send_ready.wake();
                        }
                        shared_lock_future = shared.lock();
                        Poll::Pending
                    }
                }
                Poll::Pending => Poll::Pending,
            })
            .fuse();

        select! {
            len = write_done => Ok(len),
            error = &mut self.task => Err(error),
        }
    }
/// Write the given data to the reliable channel and return once any nonzero amount of data has
/// been written.
///
/// In order to ensure that data is written to the channel in a timely manner,
/// `ReliableChannel::flush` must be called.
Write the given data to the reliable channel and return once any nonzero amount of data has
been written.

In order to ensure that data is written to the channel in a timely manner,
`ReliableChannel::flush` must be called.
Write the given data to the reliable channel and return once any nonzero amount of data has been written . In order to ensure that data is written to the channel in a timely manner ` ReliableChannel :: flush ` must be called .
pub async fn write(&mut self, data: &[u8]) -> Result<usize, Error> {
        if self.task.is_terminated() {
            return Err(Error::Shutdown);
        }
        let shared = &self.shared;
        let mut shared_lock_future = shared.lock();
        let mut write_done =
            future::poll_fn(|cx| match Pin::new(&mut shared_lock_future).poll(cx) {
                Poll::Ready(mut shared_guard) => {
                    let len = shared_guard.send_window.write(data);
                    if len > 0 {
                        Poll::Ready(len)
                    } else {
                        shared_guard.write_ready = Some(cx.waker().clone());
                        if let Some(send_ready) = shared_guard.send_ready.take() {
                            send_ready.wake();
                        }
                        shared_lock_future = shared.lock();
                        Poll::Pending
                    }
                }
                Poll::Pending => Poll::Pending,
            })
            .fuse();
        select! {
            len = write_done => Ok(len),
            error = &mut self.task => Err(error),
        }
    }
pub async fn write ( & mut self , data : & [ u8 ] ) -> Result < usize , Error > { if self . task . is_terminated ( ) { return Err ( Error :: Shutdown ) ; } let shared = & self . shared ; let mut shared_lock_future = shared . lock ( ) ; let mut write_done = future :: poll_fn ( | cx | match Pin :: new ( & mut shared_lock_future ) . poll ( cx ) { Poll :: Ready ( mut shared_guard ) => { let len = shared_guard . send_window . write ( data ) ; if len > 0 { Poll :: Ready ( len ) } else { shared_guard . write_ready = Some ( cx . waker ( ) . clone ( ) ) ; if let Some ( send_ready ) = shared_guard . send_ready . take ( ) { send_ready . wake ( ) ; } shared_lock_future = shared . lock ( ) ; Poll :: Pending } } Poll :: Pending => Poll :: Pending , } ) . fuse ( ) ; select ! { len write_done Ok ( len ) error mut self task Err ( error ) } }
Write the given data to the reliable channel and return once any nonzero amount of data has
been written.
Write the given data to the reliable channel and return once any nonzero amount of data has been written .
&mut self
data
&[u8]
&mut self
data
&[u8]