summaryrefslogtreecommitdiffstats
path: root/src/router/workers.rs
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2019-08-27 11:28:20 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2019-08-27 11:28:20 +0200
commita80e64014c21e092e35080baf29b2611d18c486a (patch)
tree6d9c044a54aa5a8c48a121397a1c4a89b37be1dc /src/router/workers.rs
parentWork on callback structure for cryptkey router (diff)
downloadwireguard-rs-a80e64014c21e092e35080baf29b2611d18c486a.tar.xz
wireguard-rs-a80e64014c21e092e35080baf29b2611d18c486a.zip
Unbox callback closures
Accepted the more verbose type signatures and added a callback to request new key-material.
Diffstat (limited to 'src/router/workers.rs')
-rw-r--r--src/router/workers.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/router/workers.rs b/src/router/workers.rs
index 4942491..4f39fb2 100644
--- a/src/router/workers.rs
+++ b/src/router/workers.rs
@@ -10,7 +10,7 @@ use std::sync::mpsc::{sync_channel, Receiver, TryRecvError};
use std::sync::{Arc, Weak};
use std::thread;
-use super::types::{Opaque, Callback};
+use super::types::{Opaque, Callback, KeyCallback};
#[derive(PartialEq)]
enum Operation {
@@ -34,7 +34,7 @@ pub struct JobInner {
pub type JobBuffer = Arc<spin::Mutex<JobInner>>;
pub type JobParallel = (Arc<thread::JoinHandle<()>>, JobBuffer);
-pub type JobInbound<T> = (Weak<DecryptionState<T>>, JobBuffer);
+pub type JobInbound<T, S, R, K> = (Weak<DecryptionState<T, S, R, K>>, JobBuffer);
pub type JobOutbound = JobBuffer;
/* Strategy for workers acquiring a new job:
@@ -82,10 +82,10 @@ fn wait_recv<T>(stopped: &AtomicBool, recv: &Receiver<T>) -> Result<T, TryRecvEr
return Err(TryRecvError::Disconnected);
}
-pub fn worker_inbound<T : Opaque>(
- device: Arc<DeviceInner<T>>, // related device
- peer: Arc<PeerInner<T>>, // related peer
- recv: Receiver<JobInbound<T>>, // in order queue
+pub fn worker_inbound<T : Opaque, S: Callback<T>, R: Callback<T>, K: KeyCallback<T>>(
+ device: Arc<DeviceInner<T, S, R, K>>, // related device
+ peer: Arc<PeerInner<T, S, R, K>>, // related peer
+ recv: Receiver<JobInbound<T, S, R, K>>, // in order queue
) {
loop {
match wait_recv(&peer.stopped, &recv) {
@@ -110,9 +110,9 @@ pub fn worker_inbound<T : Opaque>(
}
}
-pub fn worker_outbound<T : Opaque>(
- device: Arc<DeviceInner<T>>, // related device
- peer: Arc<PeerInner<T>>, // related peer
+pub fn worker_outbound<T : Opaque, S: Callback<T>, R: Callback<T>, K: KeyCallback<T>>(
+ device: Arc<DeviceInner<T, S, R, K>>, // related device
+ peer: Arc<PeerInner<T, S, R, K>>, // related peer
recv: Receiver<JobOutbound>, // in order queue
) {
loop {