message: Refactor stream recv loop into a separate function
  As suggested by mt.
diff: @@ -705,34 +705,24 @@ mod old {
  }
  }
  - fn handle(&mut self, client: &mut Connection) -> Res<bool> {
  - let mut data = vec![0; 4000];
  - while let Some(event) = client.next_event() {
  - match event {
  - ConnectionEvent::AuthenticationNeeded => {
  - client.authenticated(AuthenticationStatus::Ok, Instant::now());
  - }
  - ConnectionEvent::RecvStreamReadable { stream_id } => {
  - let mut maybe_maybe_out_file = self.streams.get_mut(&stream_id);
  - match &mut maybe_maybe_out_file {
  - None => {
  - println!("Data on unexpected stream: {}", stream_id);
  - return Ok(false);
  - }
  - Some(maybe_out_file) => {
  - let fin_recvd;
  + /// Read and maybe print received data from a stream.
  + // Returns bool: was fin received?
  + fn read_from_stream(
  + client: &mut Connection,
  + stream_id: u64,
  + output_read_data: bool,
  + maybe_out_file: &mut Option<File>,
  + ) -> Res<bool> {
  + let mut data = vec![0; 4096];
  loop {
  - let (sz, fin) = client
  - .stream_recv(stream_id, &mut data)
  - .expect("Read should succeed");
  + let (sz, fin) = client.stream_recv(stream_id, &mut data)?;
  if sz == 0 {
  - fin_recvd = fin;
  - break;
  + return Ok(fin);
  }
  if let Some(out_file) = maybe_out_file {
  out_file.write_all(&data[..sz])?;
  - } else if !self.args.output_read_data {
  + } else if !output_read_data {
  println!("READ[{}]: {} bytes", stream_id, sz);
  } else {
  println!(
  @@ -742,10 +732,31 @@ mod old {
  )
  }
  if fin {
  - fin_recvd = true;
  - break;
  + return Ok(true);
  + }
  + }
  + }
  +
  + fn handle(&mut self, client: &mut Connection) -> Res<bool> {
  + while let Some(event) = client.next_event() {
  + match event {
  + ConnectionEvent::AuthenticationNeeded => {
  + client.authenticated(AuthenticationStatus::Ok, Instant::now());
  }
  + ConnectionEvent::RecvStreamReadable { stream_id } => {
  + let mut maybe_maybe_out_file = self.streams.get_mut(&stream_id);
  + match &mut maybe_maybe_out_file {
  + None => {
  + println!("Data on unexpected stream: {}", stream_id);
  + return Ok(false);
  }
  + Some(maybe_out_file) => {
  + let fin_recvd = Self::read_from_stream(
  + client,
  + stream_id,
  + self.args.output_read_data,
  + maybe_out_file,
  + )?;
  if fin_recvd {
  if maybe_out_file.is_none() {
  