aboutsummaryrefslogtreecommitdiffstats
path: root/crates/daemon/src/aclient/history
diff options
context:
space:
mode:
Diffstat (limited to 'crates/daemon/src/aclient/history')
-rw-r--r--crates/daemon/src/aclient/history/mod.rs16
-rw-r--r--crates/daemon/src/aclient/history/store.rs24
2 files changed, 18 insertions, 22 deletions
diff --git a/crates/daemon/src/aclient/history/mod.rs b/crates/daemon/src/aclient/history/mod.rs
index ea71dcf4..f9afa5e9 100644
--- a/crates/daemon/src/aclient/history/mod.rs
+++ b/crates/daemon/src/aclient/history/mod.rs
@@ -1,14 +1,10 @@
-use core::fmt::Formatter;
use regex::RegexSet;
use rmp::decode::DecodeStringError;
use rmp::decode::ValueReadError;
use rmp::{Marker, decode::Bytes};
-use std::env;
-use std::fmt::Display;
use turtle::history::History;
use turtle_common::record::DecryptedData;
-use turtle_common::utils::uuid_v7;
use eyre::{Result, bail, eyre};
@@ -16,12 +12,12 @@ use time::OffsetDateTime;
pub(crate) mod store;
-pub(crate) const HISTORY_VERSION_V0: &str = "v0";
-pub(crate) const HISTORY_VERSION_V1: &str = "v1";
+const HISTORY_VERSION_V0: &str = "v0";
+const HISTORY_VERSION_V1: &str = "v1";
const HISTORY_RECORD_VERSION_V0: u16 = 0;
const HISTORY_RECORD_VERSION_V1: u16 = 1;
-pub(crate) const HISTORY_VERSION: &str = HISTORY_VERSION_V1;
-pub(crate) const HISTORY_TAG: &str = "history";
+const HISTORY_VERSION: &str = HISTORY_VERSION_V1;
+const HISTORY_TAG: &str = "history";
const HISTORY_AUTHOR_ENV: &str = "ATUIN_HISTORY_AUTHOR";
const HISTORY_INTENT_ENV: &str = "ATUIN_HISTORY_INTENT";
@@ -45,7 +41,7 @@ pub(crate) struct HistoryStats {
pub(crate) duration_over_time: Vec<(String, i64)>,
}
-pub(crate) trait HistoryExt: Sized {
+trait HistoryExt: Sized {
fn serialize(&self) -> Result<DecryptedData>;
fn read_optional_string(bytes: &[u8]) -> Result<(Option<String>, &[u8])>;
fn deserialize_v0(bytes: &[u8]) -> Result<Self>;
@@ -260,7 +256,7 @@ impl HistoryExt for History {
}
#[derive(Debug, Copy, Clone)]
-pub struct SettingsFilter<'a> {
+struct SettingsFilter<'a> {
pub history: &'a RegexSet,
pub cwd: &'a RegexSet,
pub secrets: bool,
diff --git a/crates/daemon/src/aclient/history/store.rs b/crates/daemon/src/aclient/history/store.rs
index c62f9068..244725eb 100644
--- a/crates/daemon/src/aclient/history/store.rs
+++ b/crates/daemon/src/aclient/history/store.rs
@@ -15,13 +15,13 @@ use super::{HISTORY_TAG, HISTORY_VERSION, HISTORY_VERSION_V0};
#[derive(Debug, Clone)]
pub(crate) struct HistoryStore {
- pub(crate) store: SqliteStore,
- pub(crate) host_id: HostId,
- pub(crate) encryption_key: [u8; 32],
+ store: SqliteStore,
+ host_id: HostId,
+ encryption_key: [u8; 32],
}
#[derive(Debug, Eq, PartialEq, Clone)]
-pub(crate) enum HistoryRecord {
+enum HistoryRecord {
Create(History), // Create a history record
Delete(HistoryId), // Delete a history record, identified by ID
}
@@ -39,7 +39,7 @@ impl HistoryRecord {
/// twice.
///
/// Deletion simply refers to the history by ID
- pub(crate) fn serialize(&self) -> Result<DecryptedData> {
+ fn serialize(&self) -> Result<DecryptedData> {
// probably don't actually need to use rmp here, but if we ever need to extend it, it's a
// nice wrapper around raw byte stuff
use rmp::encode;
@@ -65,7 +65,7 @@ impl HistoryRecord {
Ok(DecryptedData(output))
}
- pub(crate) fn deserialize(bytes: &DecryptedData, version: &str) -> Result<Self> {
+ fn deserialize(bytes: &DecryptedData, version: &str) -> Result<Self> {
use rmp::decode;
fn error_report<E: std::fmt::Debug>(err: E) -> eyre::Report {
@@ -175,7 +175,7 @@ impl HistoryStore {
Ok(())
}
- pub(crate) async fn delete(&self, id: HistoryId) -> Result<(RecordId, RecordIdx)> {
+ async fn delete(&self, id: HistoryId) -> Result<(RecordId, RecordIdx)> {
let record = HistoryRecord::Delete(id);
self.push_record(record).await
@@ -183,7 +183,7 @@ impl HistoryStore {
/// Delete a batch of history entries via the record store.
/// Returns the record IDs so the caller can run `incremental_build` when ready.
- pub(crate) async fn delete_entries(
+ async fn delete_entries(
&self,
entries: impl IntoIterator<Item = History>,
) -> Result<Vec<RecordId>> {
@@ -203,7 +203,7 @@ impl HistoryStore {
self.push_record(record).await
}
- pub(crate) async fn history(&self) -> Result<Vec<HistoryRecord>> {
+ async fn history(&self) -> Result<Vec<HistoryRecord>> {
// Atm this loads all history into memory
// Not ideal as that is potentially quite a lot, although history will be small.
let records = self.store.all_tagged(HISTORY_TAG).await?;
@@ -226,7 +226,7 @@ impl HistoryStore {
Ok(ret)
}
- pub(crate) async fn build(&self, database: &ClientSqlite) -> Result<()> {
+ async fn build(&self, database: &ClientSqlite) -> Result<()> {
// I'd like to change how we rebuild and not couple this with the database, but need to
// consider the structure more deeply. This will be easy to change.
@@ -298,7 +298,7 @@ impl HistoryStore {
/// Get a list of history IDs that exist in the store
/// Note: This currently involves loading all history into memory. This is not going to be a
/// large amount in absolute terms, but do not all it in a hot loop.
- pub(crate) async fn history_ids(&self) -> Result<HashSet<HistoryId>> {
+ async fn history_ids(&self) -> Result<HashSet<HistoryId>> {
let history = self.history().await?;
let ret = history
@@ -312,7 +312,7 @@ impl HistoryStore {
Ok(ret)
}
- pub(crate) async fn init_store(&self, db: &ClientSqlite) -> Result<()> {
+ async fn init_store(&self, db: &ClientSqlite) -> Result<()> {
todo!();
// let pb = ProgressBar::new_spinner();