pbs-tools::io::pipe: use nix Error type

there's no need to upgrade to anyhow::Error there already

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2021-10-06 15:18:06 +02:00
parent 0191759316
commit 7380c48dff
1 changed files with 2 additions and 4 deletions

View File

@ -1,7 +1,5 @@
//! I/O utilities. //! I/O utilities.
use anyhow::Error;
use proxmox::tools::fd::Fd; use proxmox::tools::fd::Fd;
/// The `BufferedRead` trait provides a single function /// The `BufferedRead` trait provides a single function
@ -11,12 +9,12 @@ pub trait BufferedRead {
/// This functions tries to fill the internal buffers, then /// This functions tries to fill the internal buffers, then
/// returns a reference to the available data. It returns an empty /// returns a reference to the available data. It returns an empty
/// buffer if `offset` points to the end of the file. /// buffer if `offset` points to the end of the file.
fn buffered_read(&mut self, offset: u64) -> Result<&[u8], Error>; fn buffered_read(&mut self, offset: u64) -> Result<&[u8], anyhow::Error>;
} }
/// safe wrapper for `nix::unistd::pipe2` defaulting to `O_CLOEXEC` and guarding the file /// safe wrapper for `nix::unistd::pipe2` defaulting to `O_CLOEXEC` and guarding the file
/// descriptors. /// descriptors.
pub fn pipe() -> Result<(Fd, Fd), Error> { pub fn pipe() -> Result<(Fd, Fd), nix::Error> {
let (pin, pout) = nix::unistd::pipe2(nix::fcntl::OFlag::O_CLOEXEC)?; let (pin, pout) = nix::unistd::pipe2(nix::fcntl::OFlag::O_CLOEXEC)?;
Ok((Fd(pin), Fd(pout))) Ok((Fd(pin), Fd(pout)))
} }