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_common/utils.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'crates/turtle/src/atuin_common/utils.rs') diff --git a/crates/turtle/src/atuin_common/utils.rs b/crates/turtle/src/atuin_common/utils.rs index d7382fb2..81eb1178 100644 --- a/crates/turtle/src/atuin_common/utils.rs +++ b/crates/turtle/src/atuin_common/utils.rs @@ -9,7 +9,7 @@ use getrandom::getrandom; use uuid::Uuid; /// Generate N random bytes, using a cryptographically secure source -pub fn crypto_random_bytes() -> [u8; N] { +pub(crate) fn crypto_random_bytes() -> [u8; N] { // rand say they are in principle safe for crypto purposes, but that it is perhaps a better // idea to use getrandom for things such as passwords. let mut ret = [0u8; N]; @@ -20,7 +20,7 @@ pub fn crypto_random_bytes() -> [u8; N] { } /// Generate N random bytes using a cryptographically secure source, return encoded as a string -pub fn crypto_random_string() -> String { +pub(crate) fn crypto_random_string() -> String { let bytes = crypto_random_bytes::(); // We only use this to create a random string, and won't be reversing it to find the original @@ -28,15 +28,15 @@ pub fn crypto_random_string() -> String { BASE64_URL_SAFE_NO_PAD.encode(bytes) } -pub fn uuid_v7() -> Uuid { +pub(crate) fn uuid_v7() -> Uuid { Uuid::now_v7() } -pub fn uuid_v4() -> String { +pub(crate) fn uuid_v4() -> String { Uuid::new_v4().as_simple().to_string() } -pub fn has_git_dir(path: &str) -> bool { +pub(crate) fn has_git_dir(path: &str) -> bool { let mut gitdir = PathBuf::from(path); gitdir.push(".git"); @@ -78,7 +78,7 @@ fn resolve_git_worktree(path: &Path) -> Option { // detect if any parent dir has a git repo in it // I really don't want to bring in libgit for something simple like this // If we start to do anything more advanced, then perhaps -pub fn in_git_repo(path: &str) -> Option { +pub(crate) fn in_git_repo(path: &str) -> Option { let mut gitdir = PathBuf::from(path); while gitdir.parent().is_some() && !has_git_dir(gitdir.to_str().unwrap()) { @@ -101,34 +101,34 @@ pub fn in_git_repo(path: &str) -> Option { // I don't want to use ProjectDirs, it puts config in awkward places on // mac. Data too. Seems to be more intended for GUI apps. -pub fn home_dir() -> PathBuf { +pub(crate) fn home_dir() -> PathBuf { directories::BaseDirs::new() .map(|d| d.home_dir().to_path_buf()) .expect("could not determine home directory") } -pub fn config_dir() -> PathBuf { +pub(crate) fn config_dir() -> PathBuf { let config_dir = std::env::var("XDG_CONFIG_HOME").map_or_else(|_| home_dir().join(".config"), PathBuf::from); config_dir.join("atuin") } -pub fn data_dir() -> PathBuf { +pub(crate) fn data_dir() -> PathBuf { let data_dir = std::env::var("XDG_DATA_HOME") .map_or_else(|_| home_dir().join(".local").join("share"), PathBuf::from); data_dir.join("atuin") } -pub fn runtime_dir() -> PathBuf { +pub(crate) fn runtime_dir() -> PathBuf { std::env::var("XDG_RUNTIME_DIR").map_or_else(|_| data_dir(), PathBuf::from) } -pub fn logs_dir() -> PathBuf { +pub(crate) fn logs_dir() -> PathBuf { home_dir().join(".atuin").join("logs") } -pub fn dotfiles_cache_dir() -> PathBuf { +pub(crate) fn dotfiles_cache_dir() -> PathBuf { // In most cases, this will be ~/.local/share/atuin/dotfiles/cache let data_dir = std::env::var("XDG_DATA_HOME") .map_or_else(|_| home_dir().join(".local").join("share"), PathBuf::from); @@ -136,7 +136,7 @@ pub fn dotfiles_cache_dir() -> PathBuf { data_dir.join("atuin").join("dotfiles").join("cache") } -pub fn get_current_dir() -> String { +pub(crate) fn get_current_dir() -> String { // Prefer PWD environment variable over cwd if available to better support symbolic links match env::var("PWD") { Ok(v) => v, @@ -147,7 +147,7 @@ pub fn get_current_dir() -> String { } } -pub fn broken_symlink>(path: P) -> bool { +pub(crate) fn broken_symlink>(path: P) -> bool { let path = path.into(); path.is_symlink() && !path.exists() } @@ -158,7 +158,7 @@ pub fn broken_symlink>(path: P) -> bool { /// Intended to help prevent control characters being printed and interpreted by the terminal when /// printing history as well as to ensure the commands that appear in the interactive search /// reflect the actual command run rather than just the printable characters. -pub trait Escapable: AsRef { +pub(crate) trait Escapable: AsRef { fn escape_control(&self) -> Cow<'_, str> { if !self.as_ref().contains(|c: char| c.is_ascii_control()) { self.as_ref().into() @@ -182,7 +182,7 @@ pub trait Escapable: AsRef { } } -pub fn unquote(s: &str) -> Result { +pub(crate) fn unquote(s: &str) -> Result { if s.chars().count() < 2 { return Err(eyre!("not enough chars")); } -- cgit v1.3.1