aboutsummaryrefslogtreecommitdiffstats
path: root/src/platform/dummy/tun.rs
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2019-12-21 00:17:31 +0100
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2019-12-21 00:17:31 +0100
commitaabefa50436af8d614520bb219d675953eeba6eb (patch)
tree9186ef07b94f12e75040d5163477ef1e549cee14 /src/platform/dummy/tun.rs
parentConstant renamed to be consistent with kernel WG (diff)
downloadwireguard-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/tun.rs')
-rw-r--r--src/platform/dummy/tun.rs75
1 files changed, 32 insertions, 43 deletions
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;