diff options
Diffstat (limited to 'src/types')
-rw-r--r-- | src/types/endpoint.rs | 2 | ||||
-rw-r--r-- | src/types/udp.rs | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/types/endpoint.rs b/src/types/endpoint.rs index d97905a..aa4dfd7 100644 --- a/src/types/endpoint.rs +++ b/src/types/endpoint.rs @@ -4,3 +4,5 @@ use std::net::SocketAddr; * is to simply use SocketAddr directly as the endpoint. */ pub trait Endpoint: Into<SocketAddr> {} + +impl<T> Endpoint for T where T: Into<SocketAddr> {} diff --git a/src/types/udp.rs b/src/types/udp.rs index 00e218f..4bf0a9c 100644 --- a/src/types/udp.rs +++ b/src/types/udp.rs @@ -21,7 +21,9 @@ pub trait Bind: Send + Sync { fn set_port(&self, port: u16) -> Result<(), Self::Error>; /// Returns the current port of the bind - fn get_port(&self) -> u16; - fn recv(&self, dst: &mut [u8]) -> Self::Endpoint; - fn send(&self, src: &[u8], dst: &Self::Endpoint); + fn get_port(&self) -> Option<u16>; + + fn recv(&self, buf: &mut [u8]) -> Result<(usize, Self::Endpoint), Self::Error>; + + fn send(&self, buf: &[u8], dst: &Self::Endpoint) -> Result<(), Self::Error>; } |