diff options
Diffstat (limited to 'src/router/types.rs')
-rw-r--r-- | src/router/types.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/router/types.rs b/src/router/types.rs index 0b5e162..2ed011b 100644 --- a/src/router/types.rs +++ b/src/router/types.rs @@ -2,6 +2,18 @@ pub trait Opaque: Send + Sync + 'static {} impl<T> Opaque for T where T: Send + Sync + 'static {} -pub trait Callback<T>: Fn(&T, bool) -> () + Sync + Send + 'static {} +/// A send/recv callback takes 3 arguments: +/// +/// * `0`, a reference to the opaque value assigned to the peer +/// * `1`, a bool indicating whether the message contained data (not just keepalive) +/// * `2`, a bool indicating whether the message was transmitted (i.e. did the peer have an associated endpoint?) +pub trait Callback<T>: Fn(&T, bool, bool) -> () + Sync + Send + 'static {} -impl<T, F> Callback<T> for F where F: Fn(&T, bool) -> () + Sync + Send + 'static {} +impl<T, F> Callback<T> for F where F: Fn(&T, bool, bool) -> () + Sync + Send + 'static {} + +/// A key callback takes 1 argument +/// +/// * `0`, a reference to the opaque value assigned to the peer +pub trait KeyCallback<T>: Fn(&T) -> () + Sync + Send + 'static {} + +impl<T, F> KeyCallback<T> for F where F: Fn(&T) -> () + Sync + Send + 'static {}
\ No newline at end of file |