Skip to main content

bucketwarden_server/
storage_commit.rs

1use super::*;
2
3#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq, Serialize)]
4pub struct StorageCommitRecord {
5    pub sequence: u64,
6    pub operation: String,
7    pub bucket: String,
8    pub key: String,
9    pub version_id: String,
10    pub committed_epoch_seconds: u64,
11    pub checksum_sha256: String,
12}
13
14impl BucketWarden {
15    pub fn storage_commit_records(&self) -> &[StorageCommitRecord] {
16        &self.storage_commits
17    }
18
19    pub(crate) fn record_storage_commit(
20        &mut self,
21        operation: &str,
22        bucket: &str,
23        key: &str,
24        version_id: &str,
25        checksum_sha256: &str,
26    ) {
27        let sequence = self.storage_commits.len() as u64 + 1;
28        self.storage_commits.push(StorageCommitRecord {
29            sequence,
30            operation: operation.to_string(),
31            bucket: bucket.to_string(),
32            key: key.to_string(),
33            version_id: version_id.to_string(),
34            committed_epoch_seconds: self.clock_epoch_seconds,
35            checksum_sha256: checksum_sha256.to_string(),
36        });
37    }
38}