pub struct FileSnapshotSet {
pub snapshots: Vec<SnapshotInfo>,
/* private fields */
}Expand description
Implementation of SnapshotSet using files on disk that exactly mirror the state
in memory, i.e., each entry in snapshots corresponds to a file in the folder, even
if the file is empty.
Snapshot files are always of the format
snapshot_<ordinal>_<shard>-of-<shard-count>_<type>.bin
Name components:
<ordinal>is a monotonically increasing sequence number<type>is one ofdiff,full, orpendingwherependingshould be renamed tofullonce the snapshot is complete and published.<shard>is the shard number (0-based) of the snapshot<shard-count>is the total number of shards in the snapshot
<ordinal> must be processed in sequence, <shard> can be processed in parallel.
Fields§
§snapshots: Vec<SnapshotInfo>Implementations§
Source§impl FileSnapshotSet
impl FileSnapshotSet
pub fn new(folder: &Path) -> Result<Self, Error>
Sourcepub fn get_latest_full_snapshot(&self) -> Option<&SnapshotInfo>
pub fn get_latest_full_snapshot(&self) -> Option<&SnapshotInfo>
Returns the latest full snapshot that has been published and is considered complete.
Sourcepub fn get_all_diff_snapshots_since(
&self,
last_full_ordinal: SnapshotOrdinal,
) -> Vec<&SnapshotInfo>
pub fn get_all_diff_snapshots_since( &self, last_full_ordinal: SnapshotOrdinal, ) -> Vec<&SnapshotInfo>
Returns all differential snapshots that have been created since the snapshot with the given ordinal number. This is useful to determine which differential snapshots need to be applied to the full snapshot to get the latest state.
Trait Implementations§
Source§impl Debug for FileSnapshotSet
impl Debug for FileSnapshotSet
Source§impl Drop for FileSnapshotSet
impl Drop for FileSnapshotSet
Source§impl SnapshotSet for FileSnapshotSet
impl SnapshotSet for FileSnapshotSet
Source§fn create_or_get_snapshot(
&mut self,
snapshot_type: SnapshotType,
shard_count: u64,
may_append_existing: bool,
) -> Result<SnapshotInfo, Error>
fn create_or_get_snapshot( &mut self, snapshot_type: SnapshotType, shard_count: u64, may_append_existing: bool, ) -> Result<SnapshotInfo, Error>
Registers a new snapshot path usable for the given snapshot type.
This will return a new snapshot path that can be used to write the snapshot to. Read more
Source§fn publish_completed_snapshot(
&mut self,
pending_snapshot_ordinal: SnapshotOrdinal,
purge_obsolete_diff_snapshots: bool,
purge_obsolete_pending_snapshots: bool,
) -> Result<(), Error>
fn publish_completed_snapshot( &mut self, pending_snapshot_ordinal: SnapshotOrdinal, purge_obsolete_diff_snapshots: bool, purge_obsolete_pending_snapshots: bool, ) -> Result<(), Error>
Publishes a pending snapshot as a full snapshot. This will rename the snapshot file
to indicate that it is a full snapshot and considered complete.
purge_obsolete_diff_snapshots specifies if differential snapshots that
are now obsolete should be auto-deleted.
purge_obsolete_pending_snapshots specifies if pending snapshots that
precede the now completed snapshot should be auto-deleted.Source§fn get_snapshots_to_restore(&self) -> Vec<&SnapshotInfo>
fn get_snapshots_to_restore(&self) -> Vec<&SnapshotInfo>
Returns all snapshots that need to be restored in order to get the latest state.
This includes the latest full snapshot and all differential snapshots since then.
Source§impl SnapshotSetAdmin for FileSnapshotSet
impl SnapshotSetAdmin for FileSnapshotSet
Source§fn prune_backup_snapshots(
&mut self,
max_backups_keep: usize,
) -> Result<(), Error>
fn prune_backup_snapshots( &mut self, max_backups_keep: usize, ) -> Result<(), Error>
Prunes backup snapshots, keeping only the latest
max_backups_keep full snapshots.
This is useful to limit the number of backup snapshots that are kept around.
Warning: This will delete files from the file system.Auto Trait Implementations§
impl Freeze for FileSnapshotSet
impl RefUnwindSafe for FileSnapshotSet
impl Send for FileSnapshotSet
impl Sync for FileSnapshotSet
impl Unpin for FileSnapshotSet
impl UnwindSafe for FileSnapshotSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more