Trait bevy_save::Pipeline

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

    // Required method
    fn key(&self) -> Self::Key<'_>;

    // Provided methods
    fn build(app: &mut App) { ... }
    fn capture(builder: SnapshotBuilder<'_>) -> Snapshot { ... }
    fn capture_seed(&self, builder: SnapshotBuilder<'_>) -> Snapshot { ... }
    fn apply(world: &mut World, snapshot: &Snapshot) -> Result<(), Error> { ... }
    fn apply_seed(
        &self,
        world: &mut World,
        snapshot: &Snapshot
    ) -> Result<(), Error> { ... }
}
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.

Provided Methods§

source

fn build(app: &mut App)

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

source

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

Retrieve a Snapshot from the [World].

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

You must extract Rollbacks if you want this pipeline to handle rollbacks properly.

source

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

Retrieve a Snapshot from the [World], using the Pipeline as a seed.

This is usually used for partial snapshots.

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

You must extract Rollbacks if you want this pipeline to handle rollbacks properly.

source

fn apply(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.

source

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

Apply a Snapshot to the [World], using the Pipeline as a seed.

This is usually used for partial snapshots.

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a> Pipeline for &'a str

§

type Backend = FileIO

§

type Format = RMPFormat

§

type Key<'k> = &'k str

source§

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

Implementors§

source§

impl<'a> Pipeline for DebugPipeline<'a>

§

type Backend = DebugFileIO

§

type Format = JSONFormat

§

type Key<'k> = &'k str