chiark / gitweb /
mgmtchannel: Insist that client connections are Debug
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 1 Jun 2021 10:30:27 +0000 (11:30 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 1 Jun 2021 12:59:29 +0000 (13:59 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/mgmtchannel.rs

index a4771e09ab7b4956bbf5b9042bb38e6782e2ce0a..c1dcc431ca1e6f5983b5368e75b3b2ed7a28cf54 100644 (file)
@@ -46,10 +46,15 @@ impl<R,W> Debug for MgmtChannel<R,W> where R: Read, W: Write {
 }
 
 pub type ClientMgmtChannel = MgmtChannel<
-    Box<dyn Read  + Send + 'static>,
-    Box<dyn Write + Send + 'static>,
+    Box<dyn ReadDebug  + Send + 'static>,
+    Box<dyn WriteDebug + Send + 'static>,
   >;
 
+pub trait ReadDebug: Read + Debug { }
+pub trait WriteDebug: Write + Debug { }
+impl<T> ReadDebug for T where T: Read + Debug { }
+impl<T> WriteDebug for T where T: Write + Debug { }
+
 impl ClientMgmtChannel {
   #[throws(AE)]
   pub fn connect(socket_path: &str) -> Self {
@@ -62,8 +67,8 @@ impl ClientMgmtChannel {
   }
 
   pub fn new_boxed<R,W>(read: R, write: W) -> Self
-  where R: Read  + Send + 'static,
-        W: Write + Send + 'static {
+  where R: ReadDebug  + Send + 'static,
+        W: WriteDebug + Send + 'static {
     MgmtChannel::new_raw(Box::new(read), Box::new(write))
   }
 }