ic_backup/ops/persistence/
mod.rs1mod artifact_commit;
4mod command_lifetime_lock;
5mod file_lock;
6mod journal_lock;
7mod json;
8mod layout_lifetime;
9
10pub use artifact_commit::{ArtifactCommitOutcome, commit_artifact_directory};
11pub use command_lifetime_lock::{
12 COMMAND_CUSTODY_DESCRIPTOR_ENV, CommandLifetimeLock, CommandLifetimeLockError,
13 CommandQuiescenceGuard,
14};
15pub use journal_lock::{JournalLock, JournalLockError};
16pub use json::{create_json_durable, read_json, write_json_durable};
17pub use layout_lifetime::{BackupLayoutGuard, MAX_RESTORE_REFERENCE_BYTES};
18
19use crate::{model::artifacts::ChecksumError, ops::artifacts::ArtifactError};
20use std::io;
21use thiserror::Error;
22
23#[derive(Debug, Error)]
25pub enum PersistenceError {
26 #[error("backup layout changed while held: {path:?}")]
28 LayoutChanged {
29 path: std::path::PathBuf,
31 },
32 #[error("unsafe restore reference entry: {path:?}")]
34 InvalidRestoreReferences {
35 path: std::path::PathBuf,
37 },
38 #[error(transparent)]
40 RestoreReference(#[from] crate::model::restore_references::RestoreReferenceError),
41 #[error(transparent)]
43 Io(#[from] io::Error),
44 #[error(transparent)]
46 Json(#[from] serde_json::Error),
47 #[error("record exceeds byte limit {limit}")]
49 RecordTooLarge {
50 limit: u64,
52 },
53 #[error(transparent)]
55 Artifact(#[from] ArtifactError),
56 #[error(transparent)]
58 Checksum(#[from] ChecksumError),
59 #[error("artifact commit paths must be distinct siblings: {temporary}, {canonical}")]
61 ArtifactCommitPathMismatch {
62 temporary: String,
64 canonical: String,
66 },
67 #[error("artifact commit has conflicting paths: {temporary}, {canonical}")]
69 ArtifactCommitPathConflict {
70 temporary: String,
72 canonical: String,
74 },
75 #[error("artifact commit is missing both paths: {temporary}, {canonical}")]
77 ArtifactCommitPathMissing {
78 temporary: String,
80 canonical: String,
82 },
83 #[error("durable artifact publication is unsupported on {platform}")]
85 ArtifactCommitUnsupportedPlatform {
86 platform: &'static str,
88 },
89 #[error("unsupported artifact entry at {path}: {kind}")]
91 UnsupportedArtifactEntry {
92 path: String,
94 kind: String,
96 },
97}