Return the amount of bytes sent from UdpSocket::send_slice.
parent
f01ce30466
commit
7f095f6429
|
@ -118,7 +118,7 @@ fn main() {
|
|||
let data = b"yo dawg\n";
|
||||
debug!("udp:6969 send data: {:?}",
|
||||
str::from_utf8(data.as_ref()).unwrap());
|
||||
socket.send_slice(data, endpoint).unwrap()
|
||||
socket.send_slice(data, endpoint).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -155,9 +155,11 @@ impl<'a, 'b> UdpSocket<'a, 'b> {
|
|||
/// Enqueue a packet to be sent to a given remote endpoint, and fill it from a slice.
|
||||
///
|
||||
/// See also [send](#method.send).
|
||||
pub fn send_slice(&mut self, data: &[u8], endpoint: IpEndpoint) -> Result<(), Error> {
|
||||
pub fn send_slice(&mut self, data: &[u8], endpoint: IpEndpoint) -> Result<usize, Error> {
|
||||
let buffer = try!(self.send(data.len(), endpoint));
|
||||
Ok(buffer.copy_from_slice(data))
|
||||
let data = &data[..buffer.len()];
|
||||
buffer.copy_from_slice(data);
|
||||
Ok(data.len())
|
||||
}
|
||||
|
||||
/// Check whether the receive buffer is full.
|
||||
|
|
Loading…
Reference in New Issue