Struct PgsMemoryBuffer

Source
pub struct PgsMemoryBuffer { /* private fields */ }
Expand description

A memory buffer that supports reading and seeking operations.

Implementations§

Source§

impl PgsMemoryBuffer

Source

pub fn new() -> Self

Creates a new PgsMemoryBuffer instance.

§Returns

Returns a new PgsMemoryBuffer with an empty buffer and position set to 0.

Source

pub fn read_bytes<const N: usize>(&mut self) -> Result<[u8; N]>

Reads a fixed number of bytes into a fixed-size array.

§Arguments
  • N - The number of bytes to read, specified as a constant generic parameter.
§Returns

Returns a Result containing an array of bytes on success, or an Error if the read operation fails.

Source

pub fn read_into_vec(&mut self, length: u32) -> Result<Vec<u8>>

Reads a specified number of bytes into a Vec<u8>.

§Arguments
  • length - The number of bytes to read.
§Returns

Returns a Result containing a vector of bytes on success, or an Error if the read operation fails.

Source

pub fn remaining_slice(&self) -> &[u8]

Returns a slice of the remaining bytes in the buffer.

§Returns

Returns a slice of the remaining bytes starting from the current position.

Trait Implementations§

Source§

impl Default for PgsMemoryBuffer

Source§

fn default() -> PgsMemoryBuffer

Returns the “default value” for a type. Read more
Source§

impl From<&[u8]> for PgsMemoryBuffer

Source§

fn from(buffer: &[u8]) -> Self

Creates a PgsMemoryBuffer from a byte slice.

§Arguments
  • buffer - A byte slice to initialize the PgsMemoryBuffer.
§Returns

Returns a PgsMemoryBuffer containing the provided slice.

Source§

impl From<Vec<u8>> for PgsMemoryBuffer

Source§

fn from(buffer: Vec<u8>) -> Self

Creates a PgsMemoryBuffer from a Vec<u8>.

§Arguments
  • buffer - A Vec<u8> to initialize the PgsMemoryBuffer.
§Returns

Returns a PgsMemoryBuffer containing the provided vector.

Source§

impl PgsSeek for PgsMemoryBuffer

Source§

fn seek(&mut self, to: usize) -> Result<usize>

Seeks to a specific position in the data. Read more
Source§

fn pos(&mut self) -> Result<usize>

Gets the current position in the data. Read more
Source§

fn len(&self) -> Result<usize>

Gets the total length of the data. Read more
Source§

fn is_empty(&self) -> bool

Checks if the data is non-empty. Read more
Source§

impl Read for PgsMemoryBuffer

Source§

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

Reads bytes from the buffer into the provided slice.

§Arguments
  • buffer - A mutable byte slice to read into.
§Returns

Returns a Result containing the number of bytes read on success, or an Error if the read operation fails.

Source§

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

Reads bytes from the buffer into the provided slice, ensuring that the exact number of bytes is read.

§Arguments
  • buffer - A mutable byte slice to read into.
§Returns

Returns a Result indicating success or failure of the read operation.

1.36.0 · Source§

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>

Like read, except that it reads into a slice of buffers. Read more
Source§

fn is_read_vectored(&self) -> bool

🔬This is a nightly-only experimental API. (can_vector)
Determines if this Reader has an efficient read_vectored implementation. Read more
1.0.0 · Source§

fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>

Reads all bytes until EOF in this source, placing them into buf. Read more
1.0.0 · Source§

fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>

Reads all bytes until EOF in this source, appending them to buf. Read more
Source§

fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Pull some bytes from this source into the specified buffer. Read more
Source§

fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>

🔬This is a nightly-only experimental API. (read_buf)
Reads the exact number of bytes required to fill cursor. Read more
1.0.0 · Source§

fn by_ref(&mut self) -> &mut Self
where Self: Sized,

Creates a “by reference” adaptor for this instance of Read. Read more
1.0.0 · Source§

fn bytes(self) -> Bytes<Self>
where Self: Sized,

Transforms this Read instance to an Iterator over its bytes. Read more
1.0.0 · Source§

fn chain<R>(self, next: R) -> Chain<Self, R>
where R: Read, Self: Sized,

Creates an adapter which will chain this stream with another. Read more
1.0.0 · Source§

fn take(self, limit: u64) -> Take<Self>
where Self: Sized,

Creates an adapter which will read at most limit bytes from it. 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<R> ReadBytes for R
where R: Read + ?Sized,

Source§

fn read_u8(&mut self) -> Result<u8>

Reads a single 8-bit unsigned integer. Read more
Source§

fn read_u16<T: ByteOrder>(&mut self) -> Result<u16>

Reads a 16-bit unsigned integer using the specified byte order. Read more
Source§

fn read_u24<T: ByteOrder>(&mut self) -> Result<u32>

Reads a 24-bit unsigned integer using the specified byte order. Read more
Source§

fn read_u32<T: ByteOrder>(&mut self) -> Result<u32>

Reads a 32-bit unsigned integer using the specified byte order. Read more
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.