use super::{RestoreApplyJournal, RestoreApplyJournalError, RestorePlan};
use crate::persistence::{PersistenceError, write_json_durable};
use std::path::Path;
use thiserror::Error as ThisError;
#[derive(Debug, ThisError)]
pub enum RestorePersistenceError {
#[error(transparent)]
InvalidJournal(#[from] RestoreApplyJournalError),
#[error(transparent)]
Persistence(#[from] PersistenceError),
}
pub fn write_restore_plan(path: &Path, plan: &RestorePlan) -> Result<(), RestorePersistenceError> {
write_json_durable(path, plan)?;
Ok(())
}
pub fn write_restore_apply_journal(
path: &Path,
journal: &RestoreApplyJournal,
) -> Result<(), RestorePersistenceError> {
journal.validate()?;
write_json_durable(path, journal)?;
Ok(())
}