remove trait BufferedRead from pbs-tools/src/io.rs

We do not need it.

Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
This commit is contained in:
Dietmar Maurer 2021-11-25 09:45:47 +01:00
parent fddb9bcc3e
commit 8a8a1850d0
2 changed files with 0 additions and 13 deletions

View File

@ -599,9 +599,7 @@ impl<S: ReadChunk> BufferedDynamicReader<S> {
//println!("BUFFER {} {}", self.buffered_chunk_start, end); //println!("BUFFER {} {}", self.buffered_chunk_start, end);
Ok(()) Ok(())
} }
}
impl<S: ReadChunk> pbs_tools::io::BufferedRead for BufferedDynamicReader<S> {
fn buffered_read(&mut self, offset: u64) -> Result<&[u8], Error> { fn buffered_read(&mut self, offset: u64) -> Result<&[u8], Error> {
if offset == self.archive_size { if offset == self.archive_size {
return Ok(&self.read_buffer[0..0]); return Ok(&self.read_buffer[0..0]);
@ -641,7 +639,6 @@ impl<S: ReadChunk> pbs_tools::io::BufferedRead for BufferedDynamicReader<S> {
impl<S: ReadChunk> std::io::Read for BufferedDynamicReader<S> { impl<S: ReadChunk> std::io::Read for BufferedDynamicReader<S> {
fn read(&mut self, buf: &mut [u8]) -> Result<usize, std::io::Error> { fn read(&mut self, buf: &mut [u8]) -> Result<usize, std::io::Error> {
use pbs_tools::io::BufferedRead;
use std::io::{Error, ErrorKind}; use std::io::{Error, ErrorKind};
let data = match self.buffered_read(self.read_offset) { let data = match self.buffered_read(self.read_offset) {

View File

@ -2,16 +2,6 @@
use proxmox_sys::fd::Fd; use proxmox_sys::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], 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), nix::Error> { pub fn pipe() -> Result<(Fd, Fd), nix::Error> {