Trait SaveData

Source
pub trait SaveData: Sized {
    const SCHEMA: u64;
    const VERSION: u32;
    const MAX_BYTES: usize = 8_388_608usize;

    // Required methods
    fn write(&self, document: &mut Document) -> Result<(), SaveError>;
    fn read(document: &Document) -> Result<Self, SaveError>;

    // Provided methods
    fn encode(&self, generation: u64) -> Result<Vec<u8>, SaveError> { ... }
    fn decode(data: &[u8]) -> Result<(Self, u64), SaveError> { ... }
}
Expand description

Implement explicit older-version migration in read(); reject newer versions. Decode into a temporary value and validate it before returning to the host.

Required Associated Constants§

Provided Associated Constants§

Source

const MAX_BYTES: usize = 8_388_608usize

Required Methods§

Source

fn write(&self, document: &mut Document) -> Result<(), SaveError>

Source

fn read(document: &Document) -> Result<Self, SaveError>

Provided Methods§

Source

fn encode(&self, generation: u64) -> Result<Vec<u8>, SaveError>

Source

fn decode(data: &[u8]) -> Result<(Self, u64), SaveError>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl SaveData for TouchLayoutSettings

Source§

const SCHEMA: u64 = 5_068_894_080_315_115_569u64

Source§

const VERSION: u32 = 1u32

Source§

const MAX_BYTES: usize = 512usize

Source§

impl SaveData for TuningProfile

Source§

const SCHEMA: u64 = 5_068_894_105_967_873_607u64

Source§

const VERSION: u32 = 1u32

Source§

const MAX_BYTES: usize = 256usize

Source§

impl SaveData for Preferences

Source§

const SCHEMA: u64 = 5_068_889_694_885_270_321u64

Source§

const VERSION: u32 = 5u32

Source§

const MAX_BYTES: usize = 1_024usize

Source§

impl SaveData for RecordBook

Source§

const SCHEMA: u64 = 5_068_891_838_040_986_180u64

Source§

const VERSION: u32 = 1u32

Source§

const MAX_BYTES: usize = 16_384usize

Source§

impl<const N: usize> SaveData for ObjectiveSnapshot<N>

Source§

const SCHEMA: u64 = 5_068_888_526_737_982_292u64

Source§

const VERSION: u32 = 1u32

Source§

const MAX_BYTES: usize = 2_048usize