fjall/
tracked_snapshot.rs

1// Copyright (c) 2024-present, fjall-rs
2// This source code is licensed under both the Apache 2.0 and MIT License
3// (found in the LICENSE-* files in the repository)
4
5use crate::snapshot_nonce::SnapshotNonce;
6
7/// A snapshot captures a read-only point-in-time view of the tree at the time the snapshot was created
8///
9/// As long as the snapshot is open, old versions of objects will not be evicted as to
10/// keep the snapshot consistent. Thus, snapshots should only be kept around for as little as possible.
11///
12/// Snapshots do not persist across restarts.
13pub struct TrackedSnapshot {
14    inner: lsm_tree::Snapshot,
15
16    #[allow(unused)]
17    nonce: SnapshotNonce,
18}
19
20impl std::ops::Deref for TrackedSnapshot {
21    type Target = lsm_tree::Snapshot;
22
23    fn deref(&self) -> &Self::Target {
24        &self.inner
25    }
26}
27
28impl TrackedSnapshot {
29    pub(crate) fn new(snapshot: lsm_tree::Snapshot, nonce: SnapshotNonce) -> Self {
30        Self {
31            inner: snapshot,
32            nonce,
33        }
34    }
35}