pub struct SequentialFileReader<'a> { /* private fields */ }Expand description
Reader for non-seekable files.
Implements read-ahead using io_uring.
Implementations§
Source§impl<'a> SequentialFileReader<'a>
impl<'a> SequentialFileReader<'a>
Sourcepub fn set_path(&mut self, path: impl AsRef<Path>) -> Result<()>
pub fn set_path(&mut self, path: impl AsRef<Path>) -> Result<()>
Open file under path, check its metadata to determine read limit and add it to the reader.
See add_owned_file_to_prefetch for more details.
Sourcepub fn add_owned_file_to_prefetch(
&mut self,
file: File,
read_limit: FileSize,
) -> Result<()>
pub fn add_owned_file_to_prefetch( &mut self, file: File, read_limit: FileSize, ) -> Result<()>
Add file to read. Starts reading the file as soon as a buffer is available.
This function uses the direct io settings set in SequentialFileReaderBuilder.
A direct io mode reader is safe to use with non direct io files. However, passing direct io mode files to the reader in non direct io mode might result in an io error due to unaligned read.
It is up to the end user to ensure that they are passing files that conform to
the direct io settings of this SequentialFileReader.
The read finishes when EOF is reached or read_limit bytes are read.
The read_limit must be less than or equal to the file size when in direct io mode.
Multiple files can be added to the reader and they will be read-ahead in FIFO order.
Reader takes ownership of the file and will drop it after it’s done reading
and move_to_next_file is called.
Sourcepub fn rebind<'b>(self) -> Result<SequentialFileReader<'b>>
pub fn rebind<'b>(self) -> Result<SequentialFileReader<'b>>
Reset to idle state and re-type with a fresh lifetime 'b.
Drains the prefetch queue (cancels in-flight reads) before returning.
Trait Implementations§
Source§impl<'a> BufRead for SequentialFileReader<'a>
impl<'a> BufRead for SequentialFileReader<'a>
Source§fn consume(&mut self, amt: usize)
fn consume(&mut self, amt: usize)
amount of additional bytes from the internal buffer as having been read.
Subsequent calls to read only return bytes that have not been marked as read. Read moreSource§fn has_data_left(&mut self) -> Result<bool, Error>
fn has_data_left(&mut self) -> Result<bool, Error>
buf_read_has_data_left)read. Read more1.83.0 · Source§fn skip_until(&mut self, byte: u8) -> Result<usize, Error>
fn skip_until(&mut self, byte: u8) -> Result<usize, Error>
byte or EOF is reached. Read moreSource§impl<'a> FileBufRead<'a> for SequentialFileReader<'a>
impl<'a> FileBufRead<'a> for SequentialFileReader<'a>
Source§fn set_file(&mut self, file: &'a File, read_limit: FileSize) -> Result<()>
fn set_file(&mut self, file: &'a File, read_limit: FileSize) -> Result<()>
The SequentialFileReader must be in direct io mode if passing in direct io files.
read_limit must be less than the file size if using direct io.
See add_owned_file_to_prefetch for more details.
Source§fn add_file_to_prefetch(
&mut self,
file: &'a File,
read_limit: FileSize,
) -> Result<()>
fn add_file_to_prefetch( &mut self, file: &'a File, read_limit: FileSize, ) -> Result<()>
file for read-ahead (prefetch). Files are processed in FIFO order
by subsequent set_file calls. Read moreSource§fn get_file_offset(&self) -> FileSize
fn get_file_offset(&self) -> FileSize
fill_buf. Read moreSource§fn consume_or_skip(&mut self, amt: usize)
fn consume_or_skip(&mut self, amt: usize)
amt bytes, potentially skipping past the current buffer
into the underlying file. Read moreSource§impl<'a> Read for SequentialFileReader<'a>
impl<'a> Read for SequentialFileReader<'a>
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
buf. Read more1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_, u8>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_, u8>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(
&mut self,
cursor: BorrowedCursor<'_, u8>,
) -> Result<(), Error>
fn read_buf_exact( &mut self, cursor: BorrowedCursor<'_, u8>, ) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read more1.0.0 · Source§fn chain<R>(self, next: R) -> Chain<Self, R> ⓘ
fn chain<R>(self, next: R) -> Chain<Self, R> ⓘ
1.0.0 · Source§fn take(self, limit: u64) -> Take<Self> ⓘwhere
Self: Sized,
fn take(self, limit: u64) -> Take<Self> ⓘwhere
Self: Sized,
limit bytes from it. Read moreSource§fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>where
Self: Sized,
fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>where
Self: Sized,
read_array)