diff options
author | Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com> | 2021-08-28 21:40:32 +0000 |
---|---|---|
committer | Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com> | 2021-08-28 21:40:32 +0000 |
commit | f8bf27d5b761c071e158158b3c140d59a75b8eb8 (patch) | |
tree | c9da0a390923673ccb007488a35cb5baaa4ffca2 /src/pipe.rs | |
parent | Add CHANGELOG entry for backslash encoding contribution (diff) | |
download | miniserve-f8bf27d5b761c071e158158b3c140d59a75b8eb8.tar.gz miniserve-f8bf27d5b761c071e158158b3c140d59a75b8eb8.zip |
migrate to actix-web v4.0-beta
Diffstat (limited to '')
-rw-r--r-- | src/pipe.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/pipe.rs b/src/pipe.rs index 374a45f..6bf32c2 100644 --- a/src/pipe.rs +++ b/src/pipe.rs @@ -3,19 +3,19 @@ use actix_web::web::{Bytes, BytesMut}; use futures::channel::mpsc::Sender; use futures::executor::block_on; use futures::sink::SinkExt; -use std::io::{Error, ErrorKind, Result, Write}; +use std::io::{self, Error, ErrorKind, Write}; /// Adapter to implement the `std::io::Write` trait on a `Sender<Bytes>` from a futures channel. /// /// It uses an intermediate buffer to transfer packets. pub struct Pipe { - dest: Sender<std::result::Result<Bytes, ()>>, + dest: Sender<io::Result<Bytes>>, bytes: BytesMut, } impl Pipe { /// Wrap the given sender in a `Pipe`. - pub fn new(destination: Sender<std::result::Result<Bytes, ()>>) -> Self { + pub fn new(destination: Sender<io::Result<Bytes>>) -> Self { Pipe { dest: destination, bytes: BytesMut::new(), @@ -30,7 +30,7 @@ impl Drop for Pipe { } impl Write for Pipe { - fn write(&mut self, buf: &[u8]) -> Result<usize> { + fn write(&mut self, buf: &[u8]) -> io::Result<usize> { // We are given a slice of bytes we do not own, so we must start by copying it. self.bytes.extend_from_slice(buf); @@ -42,7 +42,7 @@ impl Write for Pipe { Ok(buf.len()) } - fn flush(&mut self) -> Result<()> { + fn flush(&mut self) -> io::Result<()> { block_on(self.dest.flush()).map_err(|e| Error::new(ErrorKind::UnexpectedEof, e)) } } |