pub fn write(&mut self, data: &[u8]) -> Result<(), Error<TcpStack::Error>> {
        // If there's an unfinished write pending, it's invalid to try to write new data. The
        // previous write must first be completed.
        assert!(self.pending_write.is_none());

        let socket = self.socket.as_mut().ok_or(Error::NotReady)?;
        self.network_stack
            .send(socket, &data)
            .or_else(|err| match err {
                nb::Error::WouldBlock => Ok(0),
                nb::Error::Other(err) => Err(Error::Network(err)),
            })
            .and_then(|written| {
                if written != data.len() {
                    // Note(unwrap): The packet should always be smaller than a single message.
                    self.pending_write
                        .replace(Vec::from_slice(&data[written..]).unwrap());
                }

                Ok(())
            })
    }
/// Write data to the interface.
///
/// # Args
/// * `packet` - The data to write.
Write data to the interface.
Write data to the interface .
pub fn write(&mut self, data: &[u8]) -> Result<(), Error<TcpStack::Error>> {
        // If there's an unfinished write pending, it's invalid to try to write new data. The
        // previous write must first be completed.
        assert!(self.pending_write.is_none());
        let socket = self.socket.as_mut().ok_or(Error::NotReady)?;
        self.network_stack
            .send(socket, &data)
            .or_else(|err| match err {
                nb::Error::WouldBlock => Ok(0),
                nb::Error::Other(err) => Err(Error::Network(err)),
            })
            .and_then(|written| {
                if written != data.len() {
                    // Note(unwrap): The packet should always be smaller than a single message.
                    self.pending_write
                        .replace(Vec::from_slice(&data[written..]).unwrap());
                }
                Ok(())
            })
    }
pub fn write ( & mut self , data : & [ u8 ] ) -> Result < ( ) , Error < TcpStack :: Error > > { // If there's an unfinished write pending, it's invalid to try to write new data. The // previous write must first be completed. assert ! ( self pending_write is_none ( ) ) ; let socket = self . socket . as_mut ( ) . ok_or ( Error :: NotReady ) ? ; self . network_stack . send ( socket , & data ) . or_else ( | err | match err { nb :: Error :: WouldBlock => Ok ( 0 ) , nb :: Error :: Other ( err ) => Err ( Error :: Network ( err ) ) , } ) . and_then ( | written | { if written != data . len ( ) { // Note(unwrap): The packet should always be smaller than a single message. self . pending_write . replace ( Vec :: from_slice ( & data [ written .. ] ) . unwrap ( ) ) ; } Ok ( ( ) ) } ) }
Write data to the interface.
Write data to the interface .
&mut self
data
&[u8]
&mut self
data
&[u8]
args
`packet` - The data to write.
` packet ` - The data to write .