pub struct FileSlicer { /* private fields */ }Expand description
Implementations§
source§impl FileSlicer
impl FileSlicer
sourcepub fn try_from_path(in_path: PathBuf) -> Result<Self>
pub fn try_from_path(in_path: PathBuf) -> Result<Self>
Try creating a new FileSlicer from a relative or absolute path
to the fixed-length file that is to be sliced.
§Errors
This function can return an error for the following reasons:
- Any I/O error was returned when trying to open the path as a file.
- Could not read the metadata of the file at the path.
sourcepub fn from_path(in_path: PathBuf) -> Self
pub fn from_path(in_path: PathBuf) -> Self
Create a new [FixedLengthFileSlicer] from a relative or absolute path to
the fixed-length file that is to be sliced.
§Panics
This function can panic for the following reasons:
- Any I/O error was returned when trying to open the path as a file.
- Could not read the metadata of the file at the path.
sourcepub fn bytes_to_read(&self) -> usize
pub fn bytes_to_read(&self) -> usize
Get the total number of bytes to read.
sourcepub fn remaining_bytes(&self) -> usize
pub fn remaining_bytes(&self) -> usize
Get the number of remaining bytes to read.
sourcepub fn set_remaining_bytes(&mut self, remaining_bytes: usize)
pub fn set_remaining_bytes(&mut self, remaining_bytes: usize)
Set the number of remaining bytes to read.
sourcepub fn bytes_processed(&self) -> usize
pub fn bytes_processed(&self) -> usize
Get the total number of processed bytes.
sourcepub fn set_bytes_processed(&mut self, bytes_processed: usize)
pub fn set_bytes_processed(&mut self, bytes_processed: usize)
Set the total number of processed bytes.
sourcepub fn bytes_overlapped(&self) -> usize
pub fn bytes_overlapped(&self) -> usize
Get the total number of overlapped bytes (due to sliding window).
sourcepub fn set_bytes_overlapped(&mut self, bytes_overlapped: usize)
pub fn set_bytes_overlapped(&mut self, bytes_overlapped: usize)
Set the total number of overlapped bytes.
sourcepub fn try_read_to_buffer(&mut self, buffer: &mut [u8]) -> Result<()>
pub fn try_read_to_buffer(&mut self, buffer: &mut [u8]) -> Result<()>
Try and read from the buffered reader into the provided buffer. This function reads enough bytes to fill the buffer, hence, it is up to the caller to ensure that the buffer has the correct and/or wanted capacity.
§Errors
If the buffered reader encounters an EOF before completely filling the buffer.
sourcepub fn read_to_buffer(&mut self, buffer: &mut [u8])
pub fn read_to_buffer(&mut self, buffer: &mut [u8])
Read from the buffered reader into the provided buffer. This function reads enough bytes to fill the buffer, hence, it is up to the caller to ensure that that buffer has the correct and/or wanted capacity.
§Panics
If the buffered reader encounters an EOF before completely filling the buffer.
sourcepub fn try_find_last_line_break(&self, bytes: &[u8]) -> Result<usize>
pub fn try_find_last_line_break(&self, bytes: &[u8]) -> Result<usize>
Try and find the last linebreak character in a byte slice and return the index of the character. The function looks specifically for a line-feed (LF) character, represented as ‘\n’ on Unix systems.
§Errors
If either the byte slice to search through was empty, or there existed no linebreak character in the byte slice.
sourcepub fn try_find_line_breaks(
&self,
bytes: &[u8],
buffer: &mut Vec<usize>,
add_starting_idx: bool,
) -> Result<()>
pub fn try_find_line_breaks( &self, bytes: &[u8], buffer: &mut Vec<usize>, add_starting_idx: bool, ) -> Result<()>
Try and find all occurances of linebreak characters in a byte slice and push the index of the byte to a provided buffer. The function looks specifically for a line-feed (LF) character, represented as ‘\n’ on Unix systems.
§Errors
If the byte slice to search through was empty.
sourcepub fn try_seek_relative(&mut self, bytes_to_seek: i64) -> Result<()>
pub fn try_seek_relative(&mut self, bytes_to_seek: i64) -> Result<()>
Try and seek relative to the current position in the buffered reader.
§Errors
Seeking to a negative offset will return an error.
sourcepub fn seek_relative(&mut self, bytes_to_seek: i64)
pub fn seek_relative(&mut self, bytes_to_seek: i64)
Seek relative to the current position in the buffered reader.
§Panics
Seeking to a negative offset will cause the program to panic.