diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-06-13 00:58:32 +0200 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-06-13 00:58:32 +0200 |
| commit | 9352a0f7cfdd5f5fc102a25d8a93218bc3dbe462 (patch) | |
| tree | b998430c307c10defb79d91abe5d30471c5c4f12 /crates/turtle/src/atuin_daemon | |
| parent | chore(treewide): Remove `cargo` warnings to 0 (diff) | |
| download | atuin-9352a0f7cfdd5f5fc102a25d8a93218bc3dbe462.zip | |
chore(treewide): Fix some of `clippy`'s error
Just a run of `cargo clippy --fix`
Diffstat (limited to 'crates/turtle/src/atuin_daemon')
| -rw-r--r-- | crates/turtle/src/atuin_daemon/client.rs | 22 | ||||
| -rw-r--r-- | crates/turtle/src/atuin_daemon/components/search.rs | 4 | ||||
| -rw-r--r-- | crates/turtle/src/atuin_daemon/components/sync.rs | 2 | ||||
| -rw-r--r-- | crates/turtle/src/atuin_daemon/search/mod.rs | 8 |
4 files changed, 18 insertions, 18 deletions
diff --git a/crates/turtle/src/atuin_daemon/client.rs b/crates/turtle/src/atuin_daemon/client.rs index 4ec1a60b..2ea7ffc5 100644 --- a/crates/turtle/src/atuin_daemon/client.rs +++ b/crates/turtle/src/atuin_daemon/client.rs @@ -97,7 +97,7 @@ impl HistoryClient { let client = HistoryServiceClient::new(channel); - Ok(HistoryClient { client }) + Ok(Self { client }) } pub(crate) async fn start_history(&mut self, h: History) -> Result<StartHistoryReply> { @@ -169,7 +169,7 @@ impl SearchClient { let client = SearchServiceClient::new(channel); - Ok(SearchClient { client }) + Ok(Self { client }) } #[instrument(skip_all, level = Level::TRACE, name = "daemon_client_search", fields(query = %query, query_id = query_id))] @@ -198,19 +198,19 @@ impl SearchClient { impl From<FilterMode> for RpcFilterMode { fn from(filter_mode: FilterMode) -> Self { match filter_mode { - FilterMode::Global => RpcFilterMode::Global, - FilterMode::Host => RpcFilterMode::Host, - FilterMode::Session => RpcFilterMode::Session, - FilterMode::Directory => RpcFilterMode::Directory, - FilterMode::Workspace => RpcFilterMode::Workspace, - FilterMode::SessionPreload => RpcFilterMode::SessionPreload, + FilterMode::Global => Self::Global, + FilterMode::Host => Self::Host, + FilterMode::Session => Self::Session, + FilterMode::Directory => Self::Directory, + FilterMode::Workspace => Self::Workspace, + FilterMode::SessionPreload => Self::SessionPreload, } } } impl From<Context> for RpcSearchContext { fn from(context: Context) -> Self { - RpcSearchContext { + Self { session_id: context.session, cwd: context.cwd, hostname: context.hostname, @@ -248,7 +248,7 @@ impl SemanticClient { let client = SemanticServiceClient::new(channel); - Ok(SemanticClient { client }) + Ok(Self { client }) } #[cfg(unix)] @@ -299,7 +299,7 @@ impl ControlClient { let client = ControlServiceClient::new(channel); - Ok(ControlClient { client }) + Ok(Self { client }) } /// Connect using settings. diff --git a/crates/turtle/src/atuin_daemon/components/search.rs b/crates/turtle/src/atuin_daemon/components/search.rs index 39df758b..bcb18865 100644 --- a/crates/turtle/src/atuin_daemon/components/search.rs +++ b/crates/turtle/src/atuin_daemon/components/search.rs @@ -365,7 +365,7 @@ impl SearchSvc for SearchGrpcService { } } -/// Convert proto FilterMode and context to IndexFilterMode. +/// Convert proto `FilterMode` and context to `IndexFilterMode`. fn convert_filter_mode( mode: FilterMode, context: &Option<search::SearchContext>, @@ -399,6 +399,6 @@ pub(crate) fn with_trailing_slash(s: &str) -> String { if s.ends_with('/') { s.to_string() } else { - format!("{}/", s) + format!("{s}/") } } diff --git a/crates/turtle/src/atuin_daemon/components/sync.rs b/crates/turtle/src/atuin_daemon/components/sync.rs index 8b5b621d..933d5ae1 100644 --- a/crates/turtle/src/atuin_daemon/components/sync.rs +++ b/crates/turtle/src/atuin_daemon/components/sync.rs @@ -130,7 +130,7 @@ async fn sync_loop(handle: DaemonHandle, mut cmd_rx: mpsc::Receiver<SyncCommand> let history_store = HistoryStore::new(handle.store().clone(), host_id, encryption_key); // Don't backoff by more than 30 mins (with a random jitter of up to 1 min) - let max_interval: f64 = 60.0 * 30.0 + rand::thread_rng().gen_range(0.0..60.0); + let max_interval: f64 = 60.0f64.mul_add(30.0, rand::thread_rng().gen_range(0.0..60.0)); let mut ticker = time::interval(Duration::from_secs(settings.daemon.sync_frequency)); diff --git a/crates/turtle/src/atuin_daemon/search/mod.rs b/crates/turtle/src/atuin_daemon/search/mod.rs index 60d923cd..04beb459 100644 --- a/crates/turtle/src/atuin_daemon/search/mod.rs +++ b/crates/turtle/src/atuin_daemon/search/mod.rs @@ -93,7 +93,7 @@ impl FrecencyData { let frequency_score = (f64::from(self.count).ln() * 20.0).min(100.0); // Apply multipliers and combine scores, then round to u32 - ((recency_score * recency_mul) + (frequency_score * frequency_mul)).round() as u32 + recency_score.mul_add(recency_mul, frequency_score * frequency_mul).round() as u32 } } @@ -261,8 +261,8 @@ type FrecencyMap = Arc<HashMap<Arc<str>, u32>>; /// although this should never happen due to precomputing the frecency map. pub(crate) struct SearchIndex { /// Map from command text to command data. - /// Using DashMap for concurrent read/write access, wrapped in Arc for sharing with scorer. - /// Keys are Arc<str> to enable zero-copy sharing with frecency_map. + /// Using `DashMap` for concurrent read/write access, wrapped in Arc for sharing with scorer. + /// Keys are Arc<str> to enable zero-copy sharing with `frecency_map`. commands: Arc<DashMap<Arc<str>, CommandData>>, /// Nucleo fuzzy matcher - items are command strings. nucleo: RwLock<Nucleo<String>>, @@ -416,7 +416,7 @@ impl SearchIndex { .global_frecency .compute(now, recency_mul, frequency_mul); // Apply overall frecency multiplier and round to u32 - let frecency = (frecency as f64 * frecency_mul).round() as u32; + let frecency = (f64::from(frecency) * frecency_mul).round() as u32; // Arc::clone is cheap - just increments reference count frecency_map.insert(Arc::clone(entry.key()), frecency); } |
