fn send(&mut self, data: Vec<u8>) -> Result<(), RPCError> {
        let mut data_sent = 0;
        loop {
            match self.iface.poll(&mut self.sockets, Instant::from_millis(0)) {
                Ok(_) => {}
                Err(e) => {
                    warn!("poll error: {}", e);
                }
            }

            if data_sent == data.len() {
                return Ok(());
            } else {
                let mut socket = self.sockets.get::<TcpSocket>(self.server_handle.unwrap());
                if socket.can_send() && socket.send_capacity() > 0 && data_sent < data.len() {
                    let end_index = data_sent + core::cmp::min(data.len(), socket.send_capacity());
                    debug!("send [{:?}-{:?}]", data_sent, end_index);
                    if let Ok(bytes_sent) = socket.send_slice(&data[data_sent..end_index]) {
                        trace!(
                            "Client sent: [{:?}-{:?}] {:?}/{:?} bytes",
                            data_sent,
                            end_index,
                            end_index,
                            data.len()
                        );
                        data_sent = data_sent + bytes_sent;
                    } else {
                        debug!("send_slice failed... trying again?");
                    }
                }
            }
        }
    }
/// send data to a remote node
send data to a remote node
send data to a remote node
fn send(&mut self, data: Vec<u8>) -> Result<(), RPCError> {
        let mut data_sent = 0;
        loop {
            match self.iface.poll(&mut self.sockets, Instant::from_millis(0)) {
                Ok(_) => {}
                Err(e) => {
                    warn!("poll error: {}", e);
                }
            }
            if data_sent == data.len() {
                return Ok(());
            } else {
                let mut socket = self.sockets.get::<TcpSocket>(self.server_handle.unwrap());
                if socket.can_send() && socket.send_capacity() > 0 && data_sent < data.len() {
                    let end_index = data_sent + core::cmp::min(data.len(), socket.send_capacity());
                    debug!("send [{:?}-{:?}]", data_sent, end_index);
                    if let Ok(bytes_sent) = socket.send_slice(&data[data_sent..end_index]) {
                        trace!(
                            "Client sent: [{:?}-{:?}] {:?}/{:?} bytes",
                            data_sent,
                            end_index,
                            end_index,
                            data.len()
                        );
                        data_sent = data_sent + bytes_sent;
                    } else {
                        debug!("send_slice failed... trying again?");
                    }
                }
            }
        }
    }
fn send ( & mut self , data : Vec < u8 > ) -> Result < ( ) , RPCError > { let mut data_sent = 0 ; loop { match self . iface . poll ( & mut self . sockets , Instant :: from_millis ( 0 ) ) { Ok ( _ ) => { } Err ( e ) => { warn ! ( " " e ) ; } } if data_sent == data . len ( ) { return Ok ( ( ) ) ; } else { let mut socket = self . sockets . get :: < TcpSocket > ( self . server_handle . unwrap ( ) ) ; if socket . can_send ( ) && socket . send_capacity ( ) > 0 && data_sent < data . len ( ) { let end_index = data_sent + core :: cmp :: min ( data . len ( ) , socket . send_capacity ( ) ) ; debug ! ( " " data_sent end_index ) ; if let Ok ( bytes_sent ) = socket . send_slice ( & data [ data_sent .. end_index ] ) { trace ! ( " " data_sent end_index end_index data len ( ) ) ; data_sent = data_sent + bytes_sent ; } else { debug ! ( " " ) ; } } } } }
send data to a remote node
send data to a remote node
&mut self
data
Vec<u8>
&mut self
data
Vec<u8>