Struct rgssad::sans_io::Reader

source ·
pub struct Reader { /* private fields */ }
Expand description

A sans-io reader state machine.

Implementations§

source§

impl Reader

source

pub fn new() -> Self

Create a new reader state machine.

source

pub fn space(&mut self) -> &mut [u8]

Get a reference to the read buffer part where new data should be written.

You should indicate how many bytes were written with fill.

source

pub fn fill(&mut self, num: usize)

Set the number of bytes written to the space buffer.

source

pub fn available_data(&self) -> usize

Get the amount of data currently in the buffer.

source

pub fn finish_seek(&mut self)

Tell the state machine that the seek it requested if finished.

This will clear any buffered bytes.

§Panics

This will panic if a seek was not requested.

source

pub fn step_read_header(&mut self) -> Result<ReaderAction<()>, Error>

Step the state machine, performing the action of reading and validating the header.

If the header has already been read, Ok(ReaderAction::Done(())) is returned and no work is performed. Calling this method is optional. The state machine will automatically read the header is if has not been read. This will never request a seek.

source

pub fn step_read_file_header( &mut self, ) -> Result<ReaderAction<FileHeader>, Error>

Step the state machine, performing the action of reading the next file header.

This will read the header if it has not been read already. This may request a seek. If you want to skip over the file data, call this again after it returns ReaderAction::Done.

source

pub fn step_read_file_data( &mut self, output_buffer: &mut [u8], ) -> Result<ReaderAction<usize>, Error>

Read file data.

This will read the header if it has not already been read. This will return Ok(ReaderAction::Done(0)) if a file header has not been read. This will never request a seek.

Trait Implementations§

source§

impl Debug for Reader

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for Reader

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for Reader

§

impl RefUnwindSafe for Reader

§

impl Send for Reader

§

impl Sync for Reader

§

impl Unpin for Reader

§

impl UnwindSafe for Reader

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>,

§

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>,

§

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.