aboutsummaryrefslogtreecommitdiffstats
path: root/src/router/types.rs
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2019-08-31 21:00:10 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2019-08-31 21:00:10 +0200
commitd16521f4c75ebee6fa068461693755a5c1863e9f (patch)
tree4eb1ace931180cee33d956da4a000c02377eb525 /src/router/types.rs
parentReduce number of type parameters in router (diff)
downloadwireguard-rs-d16521f4c75ebee6fa068461693755a5c1863e9f.tar.xz
wireguard-rs-d16521f4c75ebee6fa068461693755a5c1863e9f.zip
Added Bind trait to router
Diffstat (limited to 'src/router/types.rs')
-rw-r--r--src/router/types.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/router/types.rs b/src/router/types.rs
index f6a0311..82dcd09 100644
--- a/src/router/types.rs
+++ b/src/router/types.rs
@@ -20,10 +20,6 @@ pub trait KeyCallback<T>: Fn(&T) -> () + Sync + Send + 'static {}
impl<T, F> KeyCallback<T> for F where F: Fn(&T) -> () + Sync + Send + 'static {}
-pub trait TunCallback<T>: Fn(&T, bool, bool) -> () + Sync + Send + 'static {}
-
-pub trait BindCallback<T>: Fn(&T, bool, bool) -> () + Sync + Send + 'static {}
-
pub trait Endpoint: Send + Sync {}
pub trait Callbacks: Send + Sync + 'static {
@@ -33,16 +29,23 @@ pub trait Callbacks: Send + Sync + 'static {
type CallbackKey: KeyCallback<Self::Opaque>;
}
-pub struct CallbacksPhantom<O: Opaque, R: Callback<O>, S: Callback<O>, K: KeyCallback<O>> {
+/* Concrete implementation of "Callbacks",
+ * used to hide the constituent type parameters.
+ *
+ * This type is never instantiated.
+ */
+pub struct PhantomCallbacks<O: Opaque, R: Callback<O>, S: Callback<O>, K: KeyCallback<O>> {
_phantom_opaque: PhantomData<O>,
_phantom_recv: PhantomData<R>,
_phantom_send: PhantomData<S>,
- _phantom_key: PhantomData<K>
+ _phantom_key: PhantomData<K>,
}
-impl <O: Opaque, R: Callback<O>, S: Callback<O>, K: KeyCallback<O>> Callbacks for CallbacksPhantom<O, R, S, K> {
+impl<O: Opaque, R: Callback<O>, S: Callback<O>, K: KeyCallback<O>> Callbacks
+ for PhantomCallbacks<O, R, S, K>
+{
type Opaque = O;
type CallbackRecv = R;
type CallbackSend = S;
type CallbackKey = K;
-} \ No newline at end of file
+}