From e2b12ce9885f8266431f701bbbf412b82683649d Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 25 Nov 2021 11:14:56 +0100 Subject: [PATCH] StdChannelWriter: avoid using anyhow::Error Use a generic implementation to allow different error types. --- pbs-tools/src/sync/std_channel_writer.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pbs-tools/src/sync/std_channel_writer.rs b/pbs-tools/src/sync/std_channel_writer.rs index eb217059..c5131a12 100644 --- a/pbs-tools/src/sync/std_channel_writer.rs +++ b/pbs-tools/src/sync/std_channel_writer.rs @@ -1,24 +1,23 @@ use std::io::Write; use std::sync::mpsc::SyncSender; - -use anyhow::{Error}; +use std::string::ToString; /// Wrapper around SyncSender, which implements Write /// /// Each write in translated into a send(Vec). -pub struct StdChannelWriter(SyncSender, Error>>); +pub struct StdChannelWriter(SyncSender, E>>); -impl StdChannelWriter { - pub fn new(sender: SyncSender, Error>>) -> Self { +impl StdChannelWriter { + pub fn new(sender: SyncSender, E>>) -> Self { Self(sender) } } -impl Write for StdChannelWriter { +impl Write for StdChannelWriter { fn write(&mut self, buf: &[u8]) -> Result { self.0 .send(Ok(buf.to_vec())) - .map_err(proxmox_sys::error::io_err_other) + .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, err.to_string())) .and(Ok(buf.len())) }