use std::collections::BTreeMap;
use std::path::PathBuf;
use super::{Manifest, Snapshot};
use crate::MicrosandboxResult;
pub struct SnapshotCopyBuilder {
snapshot: Snapshot,
output_archive_path: PathBuf,
labels: BTreeMap<String, String>,
record_integrity: bool,
}
impl SnapshotCopyBuilder {
pub(super) fn new(snapshot: Snapshot, output_archive_path: PathBuf) -> Self {
Self {
snapshot,
output_archive_path,
labels: BTreeMap::new(),
record_integrity: false,
}
}
pub fn labels(mut self, labels: BTreeMap<String, String>) -> Self {
self.labels = labels;
self
}
pub fn record_integrity(mut self, enabled: bool) -> Self {
self.record_integrity = enabled;
self
}
pub async fn save(self) -> MicrosandboxResult<Manifest> {
self.snapshot
.backend
.snapshots()
.copy(
&self.snapshot,
&self.output_archive_path,
self.labels,
self.record_integrity,
)
.await
}
}