From 199563550dd41c3dfb703bd3747604a8a03cdbc5 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Thu, 11 Jun 2026 14:20:49 +0200 Subject: chore: Remove all `pub`s They will not be marked by rustc/cargo as unused, and as atuin doesn't expose an API all of them _should_ be `pub(crate)` --- crates/turtle/src/atuin_client/database.rs | 66 +++++++++++++++--------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'crates/turtle/src/atuin_client/database.rs') diff --git a/crates/turtle/src/atuin_client/database.rs b/crates/turtle/src/atuin_client/database.rs index 27f46da5..1bfe93a7 100644 --- a/crates/turtle/src/atuin_client/database.rs +++ b/crates/turtle/src/atuin_client/database.rs @@ -35,31 +35,31 @@ use super::{ }; #[derive(Clone)] -pub struct Context { - pub session: String, - pub cwd: String, - pub hostname: String, - pub host_id: String, - pub git_root: Option, +pub(crate) struct Context { + pub(crate) session: String, + pub(crate) cwd: String, + pub(crate) hostname: String, + pub(crate) host_id: String, + pub(crate) git_root: Option, } #[derive(Default, Clone)] -pub struct OptFilters { - pub exit: Option, - pub exclude_exit: Option, - pub cwd: Option, - pub exclude_cwd: Option, - pub before: Option, - pub after: Option, - pub limit: Option, - pub offset: Option, - pub reverse: bool, - pub include_duplicates: bool, +pub(crate) struct OptFilters { + pub(crate) exit: Option, + pub(crate) exclude_exit: Option, + pub(crate) cwd: Option, + pub(crate) exclude_cwd: Option, + pub(crate) before: Option, + pub(crate) after: Option, + pub(crate) limit: Option, + pub(crate) offset: Option, + pub(crate) reverse: bool, + pub(crate) include_duplicates: bool, /// Author filter. Supports special values `$all-user` and `$all-agent`. - pub authors: Vec, + pub(crate) authors: Vec, } -pub async fn current_context() -> eyre::Result { +pub(crate) async fn current_context() -> eyre::Result { let session = env::var("ATUIN_SESSION").map_err(|_| { eyre::eyre!("Failed to find $ATUIN_SESSION in the environment. Check that you have correctly set up your shell.") })?; @@ -78,7 +78,7 @@ pub async fn current_context() -> eyre::Result { } impl Context { - pub fn from_history(entry: &History) -> Self { + pub(crate) fn from_history(entry: &History) -> Self { Context { session: entry.session.to_string(), cwd: entry.cwd.to_string(), @@ -132,7 +132,7 @@ fn get_session_start_time(session_id: &str) -> Option { } #[async_trait] -pub trait Database: Send + Sync + 'static { +pub(crate) trait Database: Send + Sync + 'static { async fn save(&self, h: &History) -> Result<()>; async fn save_bulk(&self, h: &[History]) -> Result<()>; @@ -186,12 +186,12 @@ pub trait Database: Send + Sync + 'static { // Intended for use on a developer machine and not a sync server. // TODO: implement IntoIterator #[derive(Debug, Clone)] -pub struct Sqlite { - pub pool: SqlitePool, +pub(crate) struct Sqlite { + pub(crate) pool: SqlitePool, } impl Sqlite { - pub async fn new(path: impl AsRef, timeout: f64) -> Result { + pub(crate) async fn new(path: impl AsRef, timeout: f64) -> Result { let path = path.as_ref(); debug!("opening sqlite database at {path:?}"); @@ -224,7 +224,7 @@ impl Sqlite { Ok(Self { pool }) } - pub async fn sqlite_version(&self) -> Result { + pub(crate) async fn sqlite_version(&self) -> Result { sqlx::query_scalar("SELECT sqlite_version()") .fetch_one(&self.pool) .await @@ -868,7 +868,7 @@ impl Database for Sqlite { } } -pub struct Paged { +pub(crate) struct Paged { database: Box, page_size: usize, last_id: Option, @@ -877,7 +877,7 @@ pub struct Paged { } impl Paged { - pub fn new( + pub(crate) fn new( database: Box, page_size: usize, include_deleted: bool, @@ -892,7 +892,7 @@ impl Paged { } } - pub async fn next(&mut self) -> Result>> { + pub(crate) async fn next(&mut self) -> Result>> { let mut query = SqlBuilder::select_from(SqlName::new("history").alias("h").baquoted()); query.field("*").order_desc("id"); @@ -1434,12 +1434,12 @@ mod test { } } -pub struct QueryTokenizer<'a> { +pub(crate) struct QueryTokenizer<'a> { query: &'a str, last_pos: usize, } -pub enum QueryToken<'a> { +pub(crate) enum QueryToken<'a> { Match(&'a str, bool), MatchStart(&'a str, bool), MatchEnd(&'a str, bool), @@ -1449,7 +1449,7 @@ pub enum QueryToken<'a> { } impl<'a> QueryToken<'a> { - pub fn has_uppercase(&self) -> bool { + pub(crate) fn has_uppercase(&self) -> bool { match self { Self::Match(term, _) | Self::MatchStart(term, _) @@ -1459,7 +1459,7 @@ impl<'a> QueryToken<'a> { } } - pub fn is_inverse(&self) -> bool { + pub(crate) fn is_inverse(&self) -> bool { match self { Self::Match(_, inv) | Self::MatchStart(_, inv) @@ -1471,7 +1471,7 @@ impl<'a> QueryToken<'a> { } impl<'a> QueryTokenizer<'a> { - pub fn new(query: &'a str) -> Self { + pub(crate) fn new(query: &'a str) -> Self { Self { query, last_pos: 0 } } } -- cgit v1.3.1