Trait avr_oxide::util::persist::Persist

source ·
pub trait Persist: Sized {
    // Required methods
    fn load_from<R: Read>(reader: &mut R) -> PersistenceResult<Self>;
    fn save_to<W: Write>(&self, writer: &mut W) -> PersistenceResult<()>;

    // Provided methods
    fn load_from_or_default<R: Read>(reader: &mut R) -> Self
       where Self: Default { ... }
    fn load_with<R: Read>(reader: R) -> PersistenceResult<Self> { ... }
    fn load_with_or_default<R: Read>(reader: R) -> Self
       where Self: Default { ... }
    fn save_with<W: Write>(&self, writer: W) -> PersistenceResult<()> { ... }
}
Expand description

Trait implemented by types that can be read/written from a Reader/Writer as a simple binary serialisation format.

Required Methods§

source

fn load_from<R: Read>(reader: &mut R) -> PersistenceResult<Self>

Load an instance of this type from the given reader.

source

fn save_to<W: Write>(&self, writer: &mut W) -> PersistenceResult<()>

Save an instance of this type to the given writer.

Provided Methods§

source

fn load_from_or_default<R: Read>(reader: &mut R) -> Self
where Self: Default,

Load an instance of this type from the given reader, or return the Default instantiation if it cannot be loaded.

source

fn load_with<R: Read>(reader: R) -> PersistenceResult<Self>

Take the given reader and use it to load an instance of this type.

source

fn load_with_or_default<R: Read>(reader: R) -> Self
where Self: Default,

Take the given reader and use it to load an instance of this type, or return the Default instantiation if it cannot be loaded.

source

fn save_with<W: Write>(&self, writer: W) -> PersistenceResult<()>

Take the given writer and use it to save an instance of this type.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Persist for u8

source§

impl Persist for u16

source§

impl Persist for u32

source§

impl Persist for usize

source§

impl<T> Persist for Option<T>
where T: Persist,

source§

impl<T, const WIDTH: usize> Persist for [T; WIDTH]
where T: Persist,

Implementors§