Skip to main content

Load

Trait Load 

Source
pub trait Load<'a>: Sized {
    const VERSION: Version;

    // Required methods
    fn load(object: Object<'a>) -> Result<Self>;
    fn load_legacy(object: Object<'a>) -> Result<Self>;
}
Expand description

Implemented by user types that can be reloaded from a versioned Object.

This is the symmetric counterpart to super::save::Save. Implementations describe how to reconstruct Self from the manifest representation, and how to upgrade records written by older schemas via Self::load_legacy.

§Enums

Enum types dispatch on the single non-reserved key of the object (see Object::single_key) and recurse via Object::child into the payload.

Required Associated Constants§

Source

const VERSION: Version

The schema version this impl was written against.

Compared with the manifest’s version to choose between Self::load and Self::load_legacy.

Required Methods§

Source

fn load(object: Object<'a>) -> Result<Self>

Reconstruct Self from an object whose $version matches Self::VERSION.

Source

fn load_legacy(object: Object<'a>) -> Result<Self>

Reconstruct Self from an object whose $version does not match Self::VERSION.

Implementations may either upgrade the older record or refuse with error::Kind::UnknownVersion when no upgrade is possible.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§