Struct agb::save::SavePreparedBlock

source ·
pub struct SavePreparedBlock<'a> { /* private fields */ }
Expand description

A block of save memory that has been prepared for writing.

Implementations§

source§

impl<'a> SavePreparedBlock<'a>

source

pub fn write(&mut self, offset: usize, buffer: &[u8]) -> Result<(), Error>

Writes a given buffer into the save media.

Multiple overlapping writes to the same memory range without a separate call to prepare_write will leave the save data in an unpredictable state. If an error is returned, the contents of the save media is unpredictable.

Examples found in repository?
examples/save.rs (line 25)
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
fn test_save(mut gba: agb::Gba) -> Result<(), Error> {
    gba.save.init_sram();
    let mut access = gba.save.access()?;

    let mut is_save = 0;
    access.read(0, core::slice::from_mut(&mut is_save))?;

    if is_save != 0 {
        access
            .prepare_write(0..128)?
            .write(0, &(0..128).collect::<Vec<_>>())?;
    }

    Ok(())
}
source

pub fn write_and_verify( &mut self, offset: usize, buffer: &[u8] ) -> Result<(), Error>

Writes and validates a given buffer into the save media.

This function will verify that the write has completed successfully, and return an error if it has not done so.

Multiple overlapping writes to the same memory range without a separate call to prepare_write will leave the save data in an unpredictable state. If an error is returned, the contents of the save media is unpredictable.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for SavePreparedBlock<'a>

§

impl<'a> Send for SavePreparedBlock<'a>

§

impl<'a> Sync for SavePreparedBlock<'a>

§

impl<'a> Unpin for SavePreparedBlock<'a>

§

impl<'a> !UnwindSafe for SavePreparedBlock<'a>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.