chiark / gitweb /
cmdlistener: Use a concrete type for the read stream
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 16 May 2021 19:44:04 +0000 (20:44 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 17 May 2021 13:58:58 +0000 (14:58 +0100)
The write stream is still Box<dyn...>

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/cmdlistener.rs
src/packetframe.rs

index 64ad89d1f446ff71860c464e10486c82a2566735..1fcd812e60f4dcd0e8b248a22e732fba7b51b304 100644 (file)
@@ -74,11 +74,11 @@ pub const TP_ACCESS_BUNDLES: &[TP] = &[
 // ---------- management command implementations
 
 //#[throws(CSE)]
-fn execute_and_respond<R,W>(cs: &mut CommandStreamData, cmd: MgmtCommand,
-                            bulk_upload: ReadFrame<R>,
-                            for_response: &mut FrameWriter<W>)
-                            -> Result<(), CSE>
-  where R: Read, W: Write
+fn execute_and_respond<W>(cs: &mut CommandStreamData, cmd: MgmtCommand,
+                          bulk_upload: &mut ReadFrame<TimedFdReader>,
+                          for_response: &mut FrameWriter<W>)
+                          -> Result<(), CSE>
+  where W: Write
 {
   let mut bulk_download: Option<Box<dyn Read>> = None;
   let mut for_response = for_response
@@ -1351,8 +1351,9 @@ impl CommandStream<'_> {
     loop {
       use MgmtChannelReadError::*;
       match self.chan.read.read_withbulk::<MgmtCommand>() {
-        Ok((cmd, rbulk)) => {
-          execute_and_respond(&mut self.d, cmd, rbulk, &mut self.chan.write)?;
+        Ok((cmd, mut rbulk)) => {
+          execute_and_respond(&mut self.d, cmd, &mut rbulk,
+                              &mut self.chan.write)?;
         },
         Err(EOF) => break,
         Err(IO(e)) => Err(e).context("read command stream")?,
index 5effbfd7ace2e1ecc023c60a65184d6dbb9b8a95..745568bf305ed7cc5d56d0a52ad417c070496d14 100644 (file)
@@ -291,7 +291,7 @@ impl<R:Read> FrameReader<R> {
   }
 
   #[throws(MgmtChannelReadError)]
-  pub fn read_withbulk<'c,T>(&'c mut self) -> (T, ReadFrame<impl Read + 'c>)
+  pub fn read_withbulk<'c,T>(&'c mut self) -> (T, ReadFrame<'c,R>)
   where T: DeserializeOwned + Debug
   {
     let mut f = self.new_frame()?.ok_or(MgmtChannelReadError::EOF)?;