]>
git.proxmox.com Git - proxmox-backup.git/blob - src/tools/std_channel_writer.rs
2 use std
::sync
::mpsc
::SyncSender
;
6 /// Wrapper around SyncSender, which implements Write
8 /// Each write in translated into a send(Vec<u8>).
9 pub struct StdChannelWriter(SyncSender
<Result
<Vec
<u8>, Error
>>);
11 impl StdChannelWriter
{
12 pub fn new(sender
: SyncSender
<Result
<Vec
<u8>, Error
>>) -> Self {
17 impl Write
for StdChannelWriter
{
18 fn write(&mut self, buf
: &[u8]) -> Result
<usize, std
::io
::Error
> {
20 .send(Ok(buf
.to_vec()))
21 .map_err(proxmox
::sys
::error
::io_err_other
)
25 fn flush(&mut self) -> Result
<(), std
::io
::Error
> {