canic_backup/restore/persistence/
mod.rs1use super::{RestoreApplyJournal, RestoreApplyJournalError, RestorePlan};
8use crate::persistence::{PersistenceError, write_json_durable};
9
10use std::path::Path;
11
12use thiserror::Error as ThisError;
13
14#[derive(Debug, ThisError)]
22pub enum RestorePersistenceError {
23 #[error(transparent)]
24 InvalidJournal(#[from] RestoreApplyJournalError),
25
26 #[error(transparent)]
27 Persistence(#[from] PersistenceError),
28}
29
30pub fn write_restore_plan(path: &Path, plan: &RestorePlan) -> Result<(), RestorePersistenceError> {
32 write_json_durable(path, plan)?;
33 Ok(())
34}
35
36pub fn write_restore_apply_journal(
38 path: &Path,
39 journal: &RestoreApplyJournal,
40) -> Result<(), RestorePersistenceError> {
41 journal.validate()?;
42 write_json_durable(path, journal)?;
43 Ok(())
44}