move remaining client tools to pbs-tools/datastore
pbs-datastore now ended up depending on tokio after all, but that's fine for now for the fuse code I added pbs-fuse-loop (has the old fuse_loop and its 'loopdev' module) ultimately only binaries should depend on this to avoid the library link the only thins remaining to move out the client binary are the api method return types, those will need to be moved to pbs-api-types... Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
22
pbs-tools/src/io.rs
Normal file
22
pbs-tools/src/io.rs
Normal file
@ -0,0 +1,22 @@
|
||||
//! I/O utilities.
|
||||
|
||||
use anyhow::Error;
|
||||
|
||||
use proxmox::tools::fd::Fd;
|
||||
|
||||
/// The `BufferedRead` trait provides a single function
|
||||
/// `buffered_read`. It returns a reference to an internal buffer. The
|
||||
/// purpose of this traid is to avoid unnecessary data copies.
|
||||
pub trait BufferedRead {
|
||||
/// This functions tries to fill the internal buffers, then
|
||||
/// returns a reference to the available data. It returns an empty
|
||||
/// buffer if `offset` points to the end of the file.
|
||||
fn buffered_read(&mut self, offset: u64) -> Result<&[u8], Error>;
|
||||
}
|
||||
|
||||
/// safe wrapper for `nix::unistd::pipe2` defaulting to `O_CLOEXEC` and guarding the file
|
||||
/// descriptors.
|
||||
pub fn pipe() -> Result<(Fd, Fd), Error> {
|
||||
let (pin, pout) = nix::unistd::pipe2(nix::fcntl::OFlag::O_CLOEXEC)?;
|
||||
Ok((Fd(pin), Fd(pout)))
|
||||
}
|
@ -7,6 +7,7 @@ pub mod cert;
|
||||
pub mod compression;
|
||||
pub mod format;
|
||||
pub mod fs;
|
||||
pub mod io;
|
||||
pub mod json;
|
||||
pub mod lru_cache;
|
||||
pub mod nom;
|
||||
|
Reference in New Issue
Block a user