atuin_client/record/
store.rs1use async_trait::async_trait;
2use eyre::Result;
3
4use atuin_common::record::{EncryptedData, HostId, Record, RecordId, RecordIdx, RecordStatus};
5
6#[async_trait]
11pub trait Store {
12 async fn push(&self, record: &Record<EncryptedData>) -> Result<()> {
14 self.push_batch(std::iter::once(record)).await
15 }
16
17 async fn push_batch(
19 &self,
20 records: impl Iterator<Item = &Record<EncryptedData>> + Send + Sync,
21 ) -> Result<()>;
22
23 async fn get(&self, id: RecordId) -> Result<Record<EncryptedData>>;
24
25 async fn delete(&self, id: RecordId) -> Result<()>;
26 async fn delete_all(&self) -> Result<()>;
27
28 async fn len_all(&self) -> Result<u64>;
29 async fn len(&self, host: HostId, tag: &str) -> Result<u64>;
30 async fn len_tag(&self, tag: &str) -> Result<u64>;
31
32 async fn last(&self, host: HostId, tag: &str) -> Result<Option<Record<EncryptedData>>>;
33 async fn first(&self, host: HostId, tag: &str) -> Result<Option<Record<EncryptedData>>>;
34
35 async fn re_encrypt(&self, old_key: &[u8; 32], new_key: &[u8; 32]) -> Result<()>;
36 async fn verify(&self, key: &[u8; 32]) -> Result<()>;
37 async fn purge(&self, key: &[u8; 32]) -> Result<()>;
38
39 async fn next(
41 &self,
42 host: HostId,
43 tag: &str,
44 idx: RecordIdx,
45 limit: u64,
46 ) -> Result<Vec<Record<EncryptedData>>>;
47
48 async fn idx(
50 &self,
51 host: HostId,
52 tag: &str,
53 idx: RecordIdx,
54 ) -> Result<Option<Record<EncryptedData>>>;
55
56 async fn status(&self) -> Result<RecordStatus>;
57
58 async fn all_tagged(&self, tag: &str) -> Result<Vec<Record<EncryptedData>>>;
60}