Struct PgsFile

Source
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

Source

pub fn metadata(&self) -> &Metadata

Returns a reference to the file metadata.

§Returns

Returns a reference to the Metadata associated with the file.

Source

pub fn read_bytes(&mut self, buffer: &mut [u8]) -> Result<()>

Reads bytes from the file into the provided buffer.

§Arguments
  • buffer - A mutable byte slice where the data will be read into.
§Returns

Returns a Result indicating success or an Error if reading the bytes fails or if the read operation would exceed the file’s length.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for PgsFile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.