dbs_snapshot/
persist.rs

1// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Defines an abstract interface for saving/restoring a component from state.
5
6/// An abstract interface for saving/restoring a component using a specific state.
7pub trait Persist<'a>
8where
9    Self: Sized,
10{
11    /// The type of the object representing the state of the component.
12    type State;
13    /// The type of the object holding the constructor arguments.
14    type ConstructorArgs;
15    /// The type of the error that can occur while constructing the object.
16    type Error;
17
18    /// Returns the current state of the component.
19    fn save(&self) -> Self::State;
20    /// Constructs a component from a specified state.
21    fn restore(
22        constructor_args: Self::ConstructorArgs,
23        state: &Self::State,
24    ) -> std::result::Result<Self, Self::Error>;
25}