File size: 807 Bytes
d90101d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | use std::path::Path;
use std::sync::Arc;
use anyhow::Result;
use forge_domain::{Environment, Snapshot, SnapshotRepository};
pub struct ForgeFileSnapshotService {
inner: Arc<forge_snaps::SnapshotService>,
}
impl ForgeFileSnapshotService {
pub fn new(env: Environment) -> Self {
Self {
inner: Arc::new(forge_snaps::SnapshotService::new(env.snapshot_path())),
}
}
}
#[async_trait::async_trait]
impl SnapshotRepository for ForgeFileSnapshotService {
// Creation
async fn insert_snapshot(&self, file_path: &Path) -> Result<Snapshot> {
self.inner.create_snapshot(file_path.to_path_buf()).await
}
// Undo
async fn undo_snapshot(&self, file_path: &Path) -> Result<()> {
self.inner.undo_snapshot(file_path.to_path_buf()).await
}
}
|