,
+}
+
+struct Cidr {
+ pub ip: Ipv4Addr,
+ pub prefix: u8,
+}
+
+#[repr(transparent)]
+pub struct Chunk(VecDeque
);
+
+impl
Chunk
{
+ fn pop(&mut self) -> Option
{
+ self.0.pop_front()
+ }
+}
+
+trait Merge {
+ fn merge(&mut self, other: Self);
+}
+
+impl
Merge for Chunk
{
+ fn merge(&mut self, other: Self) {
+ self.0.extend(other.0);
+ }
+}
+
+struct InterfaceWorker {
+ interface: Weak,
+ used_tcp: HashMap>,
+ used_udp: HashMap>,
+ available_tcp: BTreeMap>,
+ available_udp: BTreeMap>,
+ nat: HashMap<(Ipv4Addr, u16), (Ipv4Addr, u16)>,
+ incoming_tcp: std::sync::mpsc::Receiver<(Ipv4Addr, Chunk)>,
+ incoming_udp: std::sync::mpsc::Receiver<(Ipv4Addr, Chunk)>,
+ outgoing_tcp: std::sync::mpsc::Sender<(Ipv4Addr, Chunk)>,
+ outgoing_udp: std::sync::mpsc::Sender<(Ipv4Addr, Chunk)>,
+}
+
+struct InterfaceWorkerAllocation {
+ interface_worker: InterfaceWorker,
+ outgoing_tcp: std::sync::mpsc::Sender<(Ipv4Addr, Chunk)>,
+ outgoing_udp: std::sync::mpsc::Sender<(Ipv4Addr, Chunk)>,
+}
+
+struct Interface {
+ vpc: Weak,
+ cidrs: Vec,
+ workers: BTreeMap,
+ available_tcp: BTreeMap>,
+ available_udp: BTreeMap>,
+ incoming_tcp: std::sync::mpsc::Receiver>,
+ incoming_udp: std::sync::mpsc::Receiver>,
+ // ...
+}