aboutsummaryrefslogtreecommitdiffstats
path: root/src/platform/dummy/tun.rs
diff options
context:
space:
mode:
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;