aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/atuin_common/utils.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-11 14:20:49 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-11 14:20:49 +0200
commit199563550dd41c3dfb703bd3747604a8a03cdbc5 (patch)
tree30cfa3e5539f782b7571091c742ee1c219e138fb /crates/turtle/src/atuin_common/utils.rs
parentchore: Restore db migrations (diff)
downloadatuin-199563550dd41c3dfb703bd3747604a8a03cdbc5.zip
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)`
Diffstat (limited to 'crates/turtle/src/atuin_common/utils.rs')
-rw-r--r--crates/turtle/src/atuin_common/utils.rs32
1 files changed, 16 insertions, 16 deletions
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<const N: usize>() -> [u8; N] {
+pub(crate) fn crypto_random_bytes<const N: usize>() -> [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<const N: usize>() -> [u8; N] {
}
/// Generate N random bytes using a cryptographically secure source, return encoded as a string
-pub fn crypto_random_string<const N: usize>() -> String {
+pub(crate) fn crypto_random_string<const N: usize>() -> String {
let bytes = crypto_random_bytes::<N>();
// 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<const N: usize>() -> 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<PathBuf> {
// 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<PathBuf> {
+pub(crate) fn in_git_repo(path: &str) -> Option<PathBuf> {
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<PathBuf> {
// 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<P: Into<PathBuf>>(path: P) -> bool {
+pub(crate) fn broken_symlink<P: Into<PathBuf>>(path: P) -> bool {
let path = path.into();
path.is_symlink() && !path.exists()
}
@@ -158,7 +158,7 @@ pub fn broken_symlink<P: Into<PathBuf>>(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<str> {
+pub(crate) trait Escapable: AsRef<str> {
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<str> {
}
}
-pub fn unquote(s: &str) -> Result<String> {
+pub(crate) fn unquote(s: &str) -> Result<String> {
if s.chars().count() < 2 {
return Err(eyre!("not enough chars"));
}