Struct rgssad::sans_io::Writer

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

A sans-io writer state machine.

Implementations§

source§

impl Writer

source

pub fn new() -> Self

Create a new writer state machine.

source

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

Get a reference to the output data buffer where data should be taken from.

The amount of data copied should be marked with [consume].

source

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

Get a reference to the space data buffer where data should inserted.

source

pub fn consume(&mut self, size: usize)

Consume a number of bytes from the output buffer.

source

pub fn step_write_header(&mut self) -> Result<WriterAction<()>, Error>

Step the state machine, performing the action of writing the header.

If the header has already been written, Ok(Writer::Done(())) is returned and no work is performed. Calling this method is optional. The state machine will automatically write the header is if has not been written.

source

pub fn step_write_file_header( &mut self, name: &str, size: u32, ) -> Result<WriterAction<()>, Error>

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

This will write the header if it has not been written already.

source

pub fn step_write_file_data( &mut self, size: usize, ) -> Result<WriterAction<usize>, Error>

Step the state machine, performing the action of writing the file data.

This will write the header if it has not been written already. Populate the space buffer with the bytes to write, then pass the number of bytes written to this function.

Trait Implementations§

source§

impl Debug for Writer

source§

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

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

impl Default for Writer

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for Writer

§

impl RefUnwindSafe for Writer

§

impl Send for Writer

§

impl Sync for Writer

§

impl Unpin for Writer

§

impl UnwindSafe for Writer

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.