pub mod disk;
#[cfg(test)]
pub mod memory;
use super::artifact::ArtifactData;
use super::identity::SnapshotId;
use super::manifest::SnapshotManifest;
pub trait SnapshotRead {
fn id(&self) -> &SnapshotId;
fn manifest(&self) -> &SnapshotManifest;
fn artifact(&self, namespace: &str, name: &str) -> crate::Result<ArtifactData>;
}
pub trait SnapshotWrite {
fn id(&self) -> &SnapshotId;
fn put_artifact(&mut self, namespace: &str, name: &str, bytes: Vec<u8>) -> crate::Result<()>;
}
pub trait SnapshotWriterSession {
type Read: SnapshotRead;
type Write: SnapshotWrite;
fn current_id(&self) -> Option<&SnapshotId>;
fn current(&self) -> crate::Result<Option<Self::Read>>;
fn begin(&mut self) -> crate::Result<Self::Write>;
fn publish(
&mut self,
write: Self::Write,
manifest: SnapshotManifest,
) -> crate::Result<SnapshotId>;
}
pub trait SnapshotStore {
type Read: SnapshotRead;
type Write: SnapshotWrite;
type Writer<'a>: SnapshotWriterSession<Read = Self::Read, Write = Self::Write>
where
Self: 'a;
fn current_id(&self) -> Option<&SnapshotId>;
fn current(&self) -> crate::Result<Option<Self::Read>>;
fn writer(&mut self) -> crate::Result<Self::Writer<'_>>;
}