summaryrefslogtreecommitdiffstats
path: root/atuin-client/src/record/store.rs
diff options
context:
space:
mode:
Diffstat (limited to 'atuin-client/src/record/store.rs')
-rw-r--r--atuin-client/src/record/store.rs36
1 files changed, 23 insertions, 13 deletions
diff --git a/atuin-client/src/record/store.rs b/atuin-client/src/record/store.rs
index 45d554efa..a5c156d68 100644
--- a/atuin-client/src/record/store.rs
+++ b/atuin-client/src/record/store.rs
@@ -1,8 +1,7 @@
use async_trait::async_trait;
use eyre::Result;
-use atuin_common::record::{EncryptedData, HostId, Record, RecordId, RecordIndex};
-
+use atuin_common::record::{EncryptedData, HostId, Record, RecordId, RecordIdx, RecordStatus};
/// A record store stores records
/// In more detail - we tend to need to process this into _another_ format to actually query it.
/// As is, the record store is intended as the source of truth for arbitratry data, which could
@@ -23,19 +22,30 @@ pub trait Store {
async fn get(&self, id: RecordId) -> Result<Record<EncryptedData>>;
async fn len(&self, host: HostId, tag: &str) -> Result<u64>;
- /// Get the record that follows this record
- async fn next(&self, record: &Record<EncryptedData>) -> Result<Option<Record<EncryptedData>>>;
+ async fn last(&self, host: HostId, tag: &str) -> Result<Option<Record<EncryptedData>>>;
+ async fn first(&self, host: HostId, tag: &str) -> Result<Option<Record<EncryptedData>>>;
- /// Get the first record for a given host and tag
- async fn head(&self, host: HostId, tag: &str) -> Result<Option<Record<EncryptedData>>>;
+ /// Get the next `limit` records, after and including the given index
+ async fn next(
+ &self,
+ host: HostId,
+ tag: &str,
+ idx: RecordIdx,
+ limit: u64,
+ ) -> Result<Vec<Record<EncryptedData>>>;
- /// Get the last record for a given host and tag
- async fn tail(&self, host: HostId, tag: &str) -> Result<Option<Record<EncryptedData>>>;
+ /// Get the first record for a given host and tag
+ async fn idx(
+ &self,
+ host: HostId,
+ tag: &str,
+ idx: RecordIdx,
+ ) -> Result<Option<Record<EncryptedData>>>;
- // Get the last record for all hosts for a given tag, useful for the read path of apps.
- async fn tag_tails(&self, tag: &str) -> Result<Vec<Record<EncryptedData>>>;
+ async fn status(&self) -> Result<RecordStatus>;
- // Get the latest host/tag/record tuple for every set in the store. useful for building an
- // index
- async fn tail_records(&self) -> Result<RecordIndex>;
+ /// Get every start record for a given tag, regardless of host.
+ /// Useful when actually operating on synchronized data, and will often have conflict
+ /// resolution applied.
+ async fn all_tagged(&self, tag: &str) -> Result<Vec<Record<EncryptedData>>>;
}