Skip to main content

Save

Trait Save 

Source
pub trait Save {
    const VERSION: Version;

    // Required method
    fn save(&self, context: Context<'_>) -> Result<Record<'_>>;
}
Expand description

Implemented by user types that map to a versioned Record.

This is the primary trait for structured user types. A Save impl describes the versioned schema of Self: its associated VERSION is attached to the Record produced by Self::save.

§Enums

Enum types are encoded by returning a Record with a single user key whose name is the variant tag and whose value is the variant’s payload (frequently Value::Null for unit variants). See the crate-level docs for a worked example.

Required Associated Constants§

Source

const VERSION: Version

The schema version attached to records produced by this impl.

Loaders compare this against the version stored in the manifest to decide between Load::load and Load::load_legacy.

Required Methods§

Source

fn save(&self, context: Context<'_>) -> Result<Record<'_>>

Serialize self into a Record.

Use the supplied Context to request side-car artifact writers. Use the save_fields! macro to populate the record.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§