summaryrefslogtreecommitdiffstats
path: root/src/types
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2019-08-28 16:27:26 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2019-08-28 16:27:26 +0200
commit6785aa4cb56833131b69f4d2b44301908b1a1b4c (patch)
treed9dc6ec7a3c45291f44ae3e8d707200a1b1da410 /src/types
parentRenamed confirmed -> initator on keypair (diff)
downloadwireguard-rs-6785aa4cb56833131b69f4d2b44301908b1a1b4c.tar.xz
wireguard-rs-6785aa4cb56833131b69f4d2b44301908b1a1b4c.zip
Join with worker threads on device drop
Diffstat (limited to 'src/types')
-rw-r--r--src/types/endpoint.rs2
-rw-r--r--src/types/udp.rs8
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>;
}