Trait Pipeline

Source
pub trait Pipeline {
    type Backend: for<'a> Backend<Self::Key<'a>> + Resource + Default;
    type Format: Format;
    type Key<'a>;

    // Required methods
    fn key(&self) -> Self::Key<'_>;
    fn capture(&self, builder: SnapshotBuilder<'_>) -> Snapshot;
    fn apply(&self, world: &mut World, snapshot: &Snapshot) -> Result<(), Error>;

    // Provided method
    fn build(app: &mut App) { ... }
}
Expand description

Trait that defines how exactly your app saves and loads.

Required Associated Types§

Source

type Backend: for<'a> Backend<Self::Key<'a>> + Resource + Default

The interface between the saver / loader and data storage.

Source

type Format: Format

The format used for serializing and deserializing data.

Source

type Key<'a>

Used to uniquely identify each saved Snapshot.

Required Methods§

Source

fn key(&self) -> Self::Key<'_>

Retrieve the unique identifier for the Snapshot being processed by the Pipeline.

Source

fn capture(&self, builder: SnapshotBuilder<'_>) -> Snapshot

Retrieve a Snapshot from the World.

This is where you would do any special filtering you might need.

You must extract Checkpoints if you want this pipeline to handle checkpoints properly.

Source

fn apply(&self, world: &mut World, snapshot: &Snapshot) -> Result<(), Error>

Apply a Snapshot to the World.

Entity mapping goes here, along with your spawn hook and any other transformations you might need to perform.

§Errors

If a type included in the Snapshot has not been registered with the type registry.

Provided Methods§

Source

fn build(app: &mut App)

Called when the pipeline is initialized with App::init_pipeline.

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§