pub struct PgsFile { /* private fields */ }
Expand description
A wrapper around a File
that includes file metadata and provides methods to read data.
This struct provides methods to read bytes from a file and check if the end of the file has been reached. It also maintains file metadata for boundary checking.
Implementations§
Source§impl PgsFile
impl PgsFile
Sourcepub fn metadata(&self) -> &Metadata
pub fn metadata(&self) -> &Metadata
Returns a reference to the file metadata.
§Returns
Returns a reference to the Metadata
associated with the file.
Sourcepub fn read_bytes(&mut self, buffer: &mut [u8]) -> Result<()>
pub fn read_bytes(&mut self, buffer: &mut [u8]) -> Result<()>
Sourcepub fn read_n_bytes<const N: usize>(&mut self) -> Result<[u8; N]>
pub fn read_n_bytes<const N: usize>(&mut self) -> Result<[u8; N]>
Reads a fixed number of bytes from the file into a fixed-size array.
§Type Parameters
N
- The number of bytes to read, defined as a constant generic parameter.
§Returns
Returns a Result
containing either a fixed-size array of bytes or an Error
if reading the bytes fails or if
the read operation would exceed the file’s length.
Sourcepub fn is_eof(&mut self) -> Result<bool>
pub fn is_eof(&mut self) -> Result<bool>
Checks if the current position in the file is at or past the end of the file.
§Returns
Returns a Result
containing a boolean value. true
indicates that the end of the file has been reached or
exceeded, while false
indicates that there is more data to read.