diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2019-12-21 00:17:31 +0100 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2019-12-21 00:17:31 +0100 |
commit | aabefa50436af8d614520bb219d675953eeba6eb (patch) | |
tree | 9186ef07b94f12e75040d5163477ef1e549cee14 /src/platform/dummy | |
parent | Constant renamed to be consistent with kernel WG (diff) | |
download | wireguard-rs-aabefa50436af8d614520bb219d675953eeba6eb.tar.xz wireguard-rs-aabefa50436af8d614520bb219d675953eeba6eb.zip |
Remove unused test code.
- make naming consistent with the kernel module.
- better distribution of functionality from src/wireguard.rs
- more consistent "import pattern" throughout the project.
- remove unused test code.
Diffstat (limited to 'src/platform/dummy')
-rw-r--r-- | src/platform/dummy/mod.rs | 4 | ||||
-rw-r--r-- | src/platform/dummy/tun.rs | 75 | ||||
-rw-r--r-- | src/platform/dummy/udp.rs (renamed from src/platform/dummy/bind.rs) | 23 |
3 files changed, 34 insertions, 68 deletions
diff --git a/src/platform/dummy/mod.rs b/src/platform/dummy/mod.rs index 884bd7e..2d2e7c6 100644 --- a/src/platform/dummy/mod.rs +++ b/src/platform/dummy/mod.rs @@ -1,4 +1,4 @@ -mod bind; +mod udp; mod endpoint; mod tun; @@ -8,6 +8,6 @@ mod tun; * the configuration interface and the UAPI parser. */ -pub use bind::*; pub use endpoint::*; pub use tun::*; +pub use udp::*; diff --git a/src/platform/dummy/tun.rs b/src/platform/dummy/tun.rs index 50c6654..9836b48 100644 --- a/src/platform/dummy/tun.rs +++ b/src/platform/dummy/tun.rs @@ -13,38 +13,51 @@ use std::time::Duration; use super::super::tun::*; -/* This submodule provides pure/dummy implementations of the IO interfaces - * for use in unit tests thoughout the project. - */ - -/* Error implementation */ - #[derive(Debug)] -pub enum BindError { +pub enum TunError { Disconnected, } -impl Error for BindError { - fn description(&self) -> &str { - "Generic Bind Error" +pub struct TunTest {} + +pub struct TunFakeIO { + id: u32, + store: bool, + tx: SyncSender<Vec<u8>>, + rx: Receiver<Vec<u8>>, +} + +pub struct TunReader { + id: u32, + rx: Receiver<Vec<u8>>, +} + +pub struct TunWriter { + id: u32, + store: bool, + tx: Mutex<SyncSender<Vec<u8>>>, +} + +impl fmt::Display for TunFakeIO { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "FakeIO({})", self.id) } +} - fn source(&self) -> Option<&(dyn Error + 'static)> { - None +impl fmt::Display for TunReader { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "TunReader({})", self.id) } } -impl fmt::Display for BindError { +impl fmt::Display for TunWriter { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self { - BindError::Disconnected => write!(f, "PairBind disconnected"), - } + write!(f, "TunWriter({})", self.id) } } -#[derive(Debug)] -pub enum TunError { - Disconnected, +pub struct TunStatus { + first: bool, } impl Error for TunError { @@ -63,30 +76,6 @@ impl fmt::Display for TunError { } } -pub struct TunTest {} - -pub struct TunFakeIO { - id: u32, - store: bool, - tx: SyncSender<Vec<u8>>, - rx: Receiver<Vec<u8>>, -} - -pub struct TunReader { - id: u32, - rx: Receiver<Vec<u8>>, -} - -pub struct TunWriter { - id: u32, - store: bool, - tx: Mutex<SyncSender<Vec<u8>>>, -} - -pub struct TunStatus { - first: bool, -} - impl Reader for TunReader { type Error = TunError; diff --git a/src/platform/dummy/bind.rs b/src/platform/dummy/udp.rs index 3146af8..35c905d 100644 --- a/src/platform/dummy/bind.rs +++ b/src/platform/dummy/udp.rs @@ -40,29 +40,6 @@ impl fmt::Display for BindError { } } -/* TUN implementation */ - -#[derive(Debug)] -pub enum TunError { - Disconnected, -} - -impl Error for TunError { - fn description(&self) -> &str { - "Generic Tun Error" - } - - fn source(&self) -> Option<&(dyn Error + 'static)> { - None - } -} - -impl fmt::Display for TunError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "Not Possible") - } -} - #[derive(Clone, Copy)] pub struct VoidBind {} |