diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-06-11 14:20:49 +0200 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-06-11 14:20:49 +0200 |
| commit | 199563550dd41c3dfb703bd3747604a8a03cdbc5 (patch) | |
| tree | 30cfa3e5539f782b7571091c742ee1c219e138fb /crates/turtle/src/atuin_client/settings.rs | |
| parent | chore: Restore db migrations (diff) | |
| download | atuin-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_client/settings.rs')
| -rw-r--r-- | crates/turtle/src/atuin_client/settings.rs | 404 |
1 files changed, 202 insertions, 202 deletions
diff --git a/crates/turtle/src/atuin_client/settings.rs b/crates/turtle/src/atuin_client/settings.rs index b0ffc7c1..046aad1a 100644 --- a/crates/turtle/src/atuin_client/settings.rs +++ b/crates/turtle/src/atuin_client/settings.rs @@ -15,20 +15,20 @@ use serde::{Deserialize, Serialize}; use serde_with::DeserializeFromStr; use time::{OffsetDateTime, UtcOffset, format_description::FormatItem, macros::format_description}; -pub const HISTORY_PAGE_SIZE: i64 = 100; +pub(crate) const HISTORY_PAGE_SIZE: i64 = 100; static DATA_DIR: OnceLock<PathBuf> = OnceLock::new(); static META_CONFIG: OnceLock<(String, f64)> = OnceLock::new(); static META_STORE: OnceCell<crate::atuin_client::meta::MetaStore> = OnceCell::const_new(); pub(crate) mod meta; -pub mod watcher; +pub(crate) mod watcher; /// Default sync address for Atuin's hosted service -pub const DEFAULT_SYNC_ADDRESS: &str = "https://api.atuin.sh"; +pub(crate) const DEFAULT_SYNC_ADDRESS: &str = "https://api.atuin.sh"; #[derive(Clone, Debug, Deserialize, Copy, ValueEnum, PartialEq, Serialize)] -pub enum SearchMode { +pub(crate) enum SearchMode { #[serde(rename = "prefix")] Prefix, @@ -48,7 +48,7 @@ pub enum SearchMode { } impl SearchMode { - pub fn as_str(&self) -> &'static str { + pub(crate) fn as_str(&self) -> &'static str { match self { SearchMode::Prefix => "PREFIX", SearchMode::FullText => "FULLTXT", @@ -57,7 +57,7 @@ impl SearchMode { SearchMode::DaemonFuzzy => "DAEMON", } } - pub fn next(&self, settings: &Settings) -> Self { + pub(crate) fn next(&self, settings: &Settings) -> Self { match self { SearchMode::Prefix => SearchMode::FullText, // if the user is using skim, we go to skim @@ -74,7 +74,7 @@ impl SearchMode { } #[derive(Clone, Debug, Deserialize, Copy, PartialEq, Eq, ValueEnum, Serialize)] -pub enum FilterMode { +pub(crate) enum FilterMode { #[serde(rename = "global")] Global = 0, @@ -95,7 +95,7 @@ pub enum FilterMode { } impl FilterMode { - pub fn as_str(&self) -> &'static str { + pub(crate) fn as_str(&self) -> &'static str { match self { FilterMode::Global => "GLOBAL", FilterMode::Host => "HOST", @@ -108,7 +108,7 @@ impl FilterMode { } #[derive(Clone, Debug, Deserialize, Copy, Serialize)] -pub enum ExitMode { +pub(crate) enum ExitMode { #[serde(rename = "return-original")] ReturnOriginal, @@ -119,7 +119,7 @@ pub enum ExitMode { // FIXME: Can use upstream Dialect enum if https://github.com/stevedonovan/chrono-english/pull/16 is merged // FIXME: Above PR was merged, but dependency was changed to interim (fork of chrono-english) in the ... interim #[derive(Clone, Debug, Deserialize, Copy, Serialize)] -pub enum Dialect { +pub(crate) enum Dialect { #[serde(rename = "us")] Us, @@ -143,7 +143,7 @@ impl From<Dialect> for interim::Dialect { /// /// See: <https://github.com/atuinsh/atuin/pull/1517#discussion_r1447516426> #[derive(Clone, Copy, Debug, Eq, PartialEq, DeserializeFromStr, Serialize)] -pub struct Timezone(pub UtcOffset); +pub(crate) struct Timezone(pub(crate) UtcOffset); impl fmt::Display for Timezone { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) @@ -187,7 +187,7 @@ impl FromStr for Timezone { } #[derive(Clone, Debug, Deserialize, Copy, Serialize)] -pub enum Style { +pub(crate) enum Style { #[serde(rename = "auto")] Auto, @@ -199,7 +199,7 @@ pub enum Style { } #[derive(Clone, Debug, Deserialize, Copy, Serialize)] -pub enum WordJumpMode { +pub(crate) enum WordJumpMode { #[serde(rename = "emacs")] Emacs, @@ -208,7 +208,7 @@ pub enum WordJumpMode { } #[derive(Clone, Debug, Deserialize, Copy, PartialEq, Eq, ValueEnum, Serialize)] -pub enum KeymapMode { +pub(crate) enum KeymapMode { #[serde(rename = "emacs")] Emacs, @@ -223,7 +223,7 @@ pub enum KeymapMode { } impl KeymapMode { - pub fn as_str(&self) -> &'static str { + pub(crate) fn as_str(&self) -> &'static str { match self { KeymapMode::Emacs => "EMACS", KeymapMode::VimNormal => "VIMNORMAL", @@ -239,7 +239,7 @@ impl KeymapMode { // used in HashMap (https://stackoverflow.com/questions/67142663). We instead // define an adapter type. #[derive(Clone, Debug, Deserialize, Copy, PartialEq, Eq, ValueEnum, Serialize)] -pub enum CursorStyle { +pub(crate) enum CursorStyle { #[serde(rename = "default")] DefaultUserShape, @@ -263,7 +263,7 @@ pub enum CursorStyle { } impl CursorStyle { - pub fn as_str(&self) -> &'static str { + pub(crate) fn as_str(&self) -> &'static str { match self { CursorStyle::DefaultUserShape => "DEFAULT", CursorStyle::BlinkingBlock => "BLINKBLOCK", @@ -277,13 +277,13 @@ impl CursorStyle { } #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Stats { +pub(crate) struct Stats { #[serde(default = "Stats::common_prefix_default")] - pub common_prefix: Vec<String>, // sudo, etc. commands we want to strip off + pub(crate) common_prefix: Vec<String>, // sudo, etc. commands we want to strip off #[serde(default = "Stats::common_subcommands_default")] - pub common_subcommands: Vec<String>, // kubectl, commands we should consider subcommands for + pub(crate) common_subcommands: Vec<String>, // kubectl, commands we should consider subcommands for #[serde(default = "Stats::ignored_commands_default")] - pub ignored_commands: Vec<String>, // cd, ls, etc. commands we want to completely hide from stats + pub(crate) ignored_commands: Vec<String>, // cd, ls, etc. commands we want to completely hide from stats } impl Stats { @@ -346,7 +346,7 @@ impl Default for Stats { /// (useful for local development against a Hub instance). #[derive(Clone, Copy, Debug, Deserialize, PartialEq, Eq, Serialize, Default)] #[serde(rename_all = "lowercase")] -pub enum SyncProtocol { +pub(crate) enum SyncProtocol { /// Use legacy CLI authentication (Token from CLI register/login) #[default] Legacy, @@ -359,7 +359,7 @@ pub enum SyncProtocol { /// the right auth header and endpoint style. #[cfg(feature = "sync")] #[derive(Debug, Clone)] -pub enum SyncAuth { +pub(crate) enum SyncAuth { /// Self-hosted Rust server. Uses `Authorization: Token <session>` and /// legacy endpoints. Legacy { token: String }, @@ -373,7 +373,7 @@ impl SyncAuth { /// Convert into the auth token type used by the API client. /// /// Returns an error with an actionable message for `NotLoggedIn`. - pub fn into_auth_token(self) -> Result<crate::atuin_client::api_client::AuthToken> { + pub(crate) fn into_auth_token(self) -> Result<crate::atuin_client::api_client::AuthToken> { use crate::atuin_client::api_client::AuthToken; match self { SyncAuth::Legacy { token } => Ok(AuthToken::Token(token)), @@ -383,19 +383,19 @@ impl SyncAuth { } #[derive(Clone, Debug, Deserialize, Default, Serialize)] -pub struct Keys { - pub scroll_exits: bool, - pub exit_past_line_start: bool, - pub accept_past_line_end: bool, - pub accept_past_line_start: bool, - pub accept_with_backspace: bool, - pub prefix: String, +pub(crate) struct Keys { + pub(crate) scroll_exits: bool, + pub(crate) exit_past_line_start: bool, + pub(crate) accept_past_line_end: bool, + pub(crate) accept_past_line_start: bool, + pub(crate) accept_with_backspace: bool, + pub(crate) prefix: String, } impl Keys { /// The standard default values for all `[keys]` options. /// These match the config defaults set in `builder_with_data_dir()`. - pub fn standard_defaults() -> Self { + pub(crate) fn standard_defaults() -> Self { Keys { scroll_exits: true, exit_past_line_start: true, @@ -407,7 +407,7 @@ impl Keys { } /// Returns true if any value differs from the standard defaults. - pub fn has_non_default_values(&self) -> bool { + pub(crate) fn has_non_default_values(&self) -> bool { let d = Self::standard_defaults(); self.scroll_exits != d.scroll_exits || self.exit_past_line_start != d.exit_past_line_start @@ -420,19 +420,19 @@ impl Keys { /// A single rule within a conditional keybinding config. #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct KeyRuleConfig { +pub(crate) struct KeyRuleConfig { /// Optional condition expression (e.g. "cursor-at-start", "input-empty && no-results"). /// If absent, the rule always matches. #[serde(default)] - pub when: Option<String>, + pub(crate) when: Option<String>, /// The action to perform (e.g. "exit", "cursor-left", "accept"). - pub action: String, + pub(crate) action: String, } /// A keybinding config value: either a simple action string or an ordered list of conditional rules. #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(untagged)] -pub enum KeyBindingConfig { +pub(crate) enum KeyBindingConfig { /// Simple unconditional binding: `"ctrl-c" = "return-original"` Simple(String), /// Conditional binding: `"left" = [{ when = "cursor-at-start", action = "exit" }, { action = "cursor-left" }]` @@ -442,22 +442,22 @@ pub enum KeyBindingConfig { /// User-facing keymap configuration. Each mode maps key strings to bindings. /// Keys present here override the defaults for that key; unmentioned keys keep defaults. #[derive(Clone, Debug, Deserialize, Serialize, Default)] -pub struct KeymapConfig { +pub(crate) struct KeymapConfig { #[serde(default)] - pub emacs: HashMap<String, KeyBindingConfig>, + pub(crate) emacs: HashMap<String, KeyBindingConfig>, #[serde(default, rename = "vim-normal")] - pub vim_normal: HashMap<String, KeyBindingConfig>, + pub(crate) vim_normal: HashMap<String, KeyBindingConfig>, #[serde(default, rename = "vim-insert")] - pub vim_insert: HashMap<String, KeyBindingConfig>, + pub(crate) vim_insert: HashMap<String, KeyBindingConfig>, #[serde(default)] - pub inspector: HashMap<String, KeyBindingConfig>, + pub(crate) inspector: HashMap<String, KeyBindingConfig>, #[serde(default)] - pub prefix: HashMap<String, KeyBindingConfig>, + pub(crate) prefix: HashMap<String, KeyBindingConfig>, } impl KeymapConfig { /// Returns true if no keybinding overrides are configured in any mode. - pub fn is_empty(&self) -> bool { + pub(crate) fn is_empty(&self) -> bool { self.emacs.is_empty() && self.vim_normal.is_empty() && self.vim_insert.is_empty() @@ -467,82 +467,82 @@ impl KeymapConfig { } #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Preview { - pub strategy: PreviewStrategy, +pub(crate) struct Preview { + pub(crate) strategy: PreviewStrategy, } #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Theme { +pub(crate) struct Theme { /// Name of desired theme ("default" for base) - pub name: String, + pub(crate) name: String, /// Whether any available additional theme debug should be shown - pub debug: Option<bool>, + pub(crate) debug: Option<bool>, /// How many levels of parenthood will be traversed if needed - pub max_depth: Option<u8>, + pub(crate) max_depth: Option<u8>, } #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Daemon { +pub(crate) struct Daemon { /// Use the daemon to sync /// If enabled, history hooks are routed through the daemon. #[serde(alias = "enable")] - pub enabled: bool, + pub(crate) enabled: bool, /// Automatically start and manage a local daemon when needed. - pub autostart: bool, + pub(crate) autostart: bool, /// The daemon will handle sync on an interval. How often to sync, in seconds. - pub sync_frequency: u64, + pub(crate) sync_frequency: u64, /// The path to the unix socket used by the daemon - pub socket_path: String, + pub(crate) socket_path: String, /// Path to the daemon pidfile used for process coordination. - pub pidfile_path: String, + pub(crate) pidfile_path: String, /// Use a socket passed via systemd's socket activation protocol, instead of the path - pub systemd_socket: bool, + pub(crate) systemd_socket: bool, /// The port that should be used for TCP on non unix systems - pub tcp_port: u64, + pub(crate) tcp_port: u64, } #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Search { +pub(crate) struct Search { /// The list of enabled filter modes, in order of priority. - pub filters: Vec<FilterMode>, + pub(crate) filters: Vec<FilterMode>, /// The recency score multiplier for the search index (default: 1.0). /// Values < 1.0 reduce weight, > 1.0 increase weight, 0.0 disables. - pub recency_score_multiplier: f64, + pub(crate) recency_score_multiplier: f64, /// The frequency score multiplier for the search index (default: 1.0). /// Values < 1.0 reduce weight, > 1.0 increase weight, 0.0 disables. - pub frequency_score_multiplier: f64, + pub(crate) frequency_score_multiplier: f64, /// The overall frecency score multiplier for the search index (default: 1.0). /// Applied after combining recency and frequency scores. - pub frecency_score_multiplier: f64, + pub(crate) frecency_score_multiplier: f64, } #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Tmux { +pub(crate) struct Tmux { /// Enable using atuin with tmux popup (tmux >= 3.2) - pub enabled: bool, + pub(crate) enabled: bool, /// Width of the tmux popup (percentage) - pub width: String, + pub(crate) width: String, /// Height of the tmux popup (percentage) - pub height: String, + pub(crate) height: String, } /// Log level for file logging. Maps to tracing's LevelFilter. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] -pub enum LogLevel { +pub(crate) enum LogLevel { Trace, Debug, #[default] @@ -553,7 +553,7 @@ pub enum LogLevel { impl LogLevel { /// Convert to a tracing directive string for use with EnvFilter. - pub fn as_directive(&self) -> &'static str { + pub(crate) fn as_directive(&self) -> &'static str { match self { LogLevel::Trace => "trace", LogLevel::Debug => "debug", @@ -566,102 +566,102 @@ impl LogLevel { /// Configuration for a specific log type (search or daemon). #[derive(Clone, Debug, Default, Deserialize, Serialize)] -pub struct LogConfig { +pub(crate) struct LogConfig { /// Log file name (relative to dir) or absolute path. - pub file: String, + pub(crate) file: String, /// Override global enabled setting for this log type. - pub enabled: Option<bool>, + pub(crate) enabled: Option<bool>, /// Override global level setting for this log type. - pub level: Option<LogLevel>, + pub(crate) level: Option<LogLevel>, /// Override global retention days setting for this log type. - pub retention: Option<u64>, + pub(crate) retention: Option<u64>, } #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Logs { +pub(crate) struct Logs { /// Enable file logging globally. Defaults to true. #[serde(default = "Logs::default_enabled")] - pub enabled: bool, + pub(crate) enabled: bool, /// Directory for log files. Defaults to ~/.atuin/logs - pub dir: String, + pub(crate) dir: String, /// Default log level for file logging. Defaults to "info". /// Note: ATUIN_LOG environment variable overrides this. #[serde(default)] - pub level: LogLevel, + pub(crate) level: LogLevel, /// Default retention days for log files. Defaults to 4. #[serde(default = "Logs::default_retention")] - pub retention: u64, + pub(crate) retention: u64, /// Search log settings #[serde(default)] - pub search: LogConfig, + pub(crate) search: LogConfig, /// Daemon log settings #[serde(default)] - pub daemon: LogConfig, + pub(crate) daemon: LogConfig, /// AI log settings #[serde(default)] - pub ai: LogConfig, + pub(crate) ai: LogConfig, } #[derive(Default, Clone, Debug, Deserialize, Serialize)] -pub struct Ai { +pub(crate) struct Ai { /// Whether or not the AI features are enabled. - pub enabled: Option<bool>, + pub(crate) enabled: Option<bool>, /// The address of the Atuin AI endpoint. Used for AI features like command generation. /// Only necessary for custom AI endpoints. - pub endpoint: Option<String>, + pub(crate) endpoint: Option<String>, /// The API token for the Atuin AI endpoint. Used for AI features like command generation. /// Only necessary for custom AI endpoints. - pub api_token: Option<String>, + pub(crate) api_token: Option<String>, /// Path to the AI sessions database. - pub db_path: String, + pub(crate) db_path: String, /// The maximum time in minutes that an AI session can be automatically resumed. - pub session_continue_minutes: i64, + pub(crate) session_continue_minutes: i64, /// Deprecated: use opening.send_cwd instead. Kept for backwards compatibility. #[serde(default)] - pub send_cwd: Option<bool>, + pub(crate) send_cwd: Option<bool>, /// Configuration for what context is sent in the opening AI request. #[serde(default)] - pub opening: AiOpening, + pub(crate) opening: AiOpening, /// Tool capability flags. #[serde(default)] - pub capabilities: AiCapabilities, + pub(crate) capabilities: AiCapabilities, } #[derive(Default, Clone, Debug, Deserialize, Serialize)] -pub struct AiCapabilities { +pub(crate) struct AiCapabilities { /// Whether the AI can request to search Atuin history. `None` = unset (defaults to enabled, and the ai will ask for permission). - pub enable_history_search: Option<bool>, + pub(crate) enable_history_search: Option<bool>, /// Whether the AI can request to view the stored output, if any, for Atuin history entries. `None` = unset (defaults to enabled, and the ai will ask for permission). - pub enable_history_output: Option<bool>, + pub(crate) enable_history_output: Option<bool>, /// Whether the AI can request to read and write files. `None` = unset (defaults to enabled, and the ai will ask for permission). - pub enable_file_tools: Option<bool>, + pub(crate) enable_file_tools: Option<bool>, /// Whether the AI can request to execute bash commands. `None` = unset (defaults to enabled, and the ai will ask for permission). - pub enable_command_execution: Option<bool>, + pub(crate) enable_command_execution: Option<bool>, } #[derive(Default, Clone, Debug, Deserialize, Serialize)] -pub struct AiOpening { +pub(crate) struct AiOpening { /// Whether or not to send the current working directory to the AI endpoint. - pub send_cwd: Option<bool>, + pub(crate) send_cwd: Option<bool>, /// Whether or not to send the last command as context in the opening AI request. - pub send_last_command: Option<bool>, + pub(crate) send_last_command: Option<bool>, } impl Default for Preview { @@ -730,72 +730,72 @@ impl Logs { /// Returns whether search logging is enabled. /// Uses search-specific setting if set, otherwise falls back to global. - pub fn search_enabled(&self) -> bool { + pub(crate) fn search_enabled(&self) -> bool { self.search.enabled.unwrap_or(self.enabled) } /// Returns whether daemon logging is enabled. /// Uses daemon-specific setting if set, otherwise falls back to global. - pub fn daemon_enabled(&self) -> bool { + pub(crate) fn daemon_enabled(&self) -> bool { self.daemon.enabled.unwrap_or(self.enabled) } /// Returns whether AI logging is enabled. /// Uses AI-specific setting if set, otherwise falls back to global. - pub fn ai_enabled(&self) -> bool { + pub(crate) fn ai_enabled(&self) -> bool { self.ai.enabled.unwrap_or(self.enabled) } /// Returns the log level for search logging. /// Uses search-specific setting if set, otherwise falls back to global. - pub fn search_level(&self) -> LogLevel { + pub(crate) fn search_level(&self) -> LogLevel { self.search.level.unwrap_or(self.level) } /// Returns the log level for daemon logging. /// Uses daemon-specific setting if set, otherwise falls back to global. - pub fn daemon_level(&self) -> LogLevel { + pub(crate) fn daemon_level(&self) -> LogLevel { self.daemon.level.unwrap_or(self.level) } /// Returns the log level for AI logging. /// Uses AI-specific setting if set, otherwise falls back to global. - pub fn ai_level(&self) -> LogLevel { + pub(crate) fn ai_level(&self) -> LogLevel { self.ai.level.unwrap_or(self.level) } /// Returns the retention days for search logging. /// Uses search-specific setting if set, otherwise falls back to global. - pub fn search_retention(&self) -> u64 { + pub(crate) fn search_retention(&self) -> u64 { self.search.retention.unwrap_or(self.retention) } /// Returns the retention days for daemon logging. /// Uses daemon-specific setting if set, otherwise falls back to global. - pub fn daemon_retention(&self) -> u64 { + pub(crate) fn daemon_retention(&self) -> u64 { self.daemon.retention.unwrap_or(self.retention) } /// Returns the retention days for AI logging. /// Uses AI-specific setting if set, otherwise falls back to global. - pub fn ai_retention(&self) -> u64 { + pub(crate) fn ai_retention(&self) -> u64 { self.ai.retention.unwrap_or(self.retention) } /// Returns the full path for the search log file. - pub fn search_path(&self) -> PathBuf { + pub(crate) fn search_path(&self) -> PathBuf { let path = PathBuf::from(&self.search.file); PathBuf::from(&self.dir).join(path) } /// Returns the full path for the daemon log file. - pub fn daemon_path(&self) -> PathBuf { + pub(crate) fn daemon_path(&self) -> PathBuf { let path = PathBuf::from(&self.daemon.file); PathBuf::from(&self.dir).join(path) } /// Returns the full path for the AI log file. - pub fn ai_path(&self) -> PathBuf { + pub(crate) fn ai_path(&self) -> PathBuf { let path = PathBuf::from(&self.ai.file); PathBuf::from(&self.dir).join(path) } @@ -832,7 +832,7 @@ impl Default for Tmux { // The preview height strategy also takes max_preview_height into account. #[derive(Clone, Debug, Deserialize, Copy, PartialEq, Eq, ValueEnum, Serialize)] -pub enum PreviewStrategy { +pub(crate) enum PreviewStrategy { // Preview height is calculated for the length of the selected command. #[serde(rename = "auto")] Auto, @@ -849,7 +849,7 @@ pub enum PreviewStrategy { /// Column types available for the interactive search UI. #[derive(Clone, Copy, Debug, Deserialize, PartialEq, Eq, Serialize)] #[serde(rename_all = "lowercase")] -pub enum UiColumnType { +pub(crate) enum UiColumnType { /// Command execution duration (e.g., "123ms") Duration, /// Relative time since execution (e.g., "59s ago") @@ -871,7 +871,7 @@ pub enum UiColumnType { impl UiColumnType { /// Returns the default width for this column type (in characters). /// The Command column returns 0 as it expands to fill remaining space. - pub fn default_width(&self) -> u16 { + pub(crate) fn default_width(&self) -> u16 { match self { UiColumnType::Duration => 5, // "814ms" UiColumnType::Time => 9, // "459ms ago" @@ -894,15 +894,15 @@ impl UiColumnType { /// A column configuration with type and optional custom width. /// Can be specified as just a string (uses default width) or as an object with type and width. #[derive(Clone, Debug, Serialize)] -pub struct UiColumn { - pub column_type: UiColumnType, - pub width: u16, +pub(crate) struct UiColumn { + pub(crate) column_type: UiColumnType, + pub(crate) width: u16, /// If true, this column expands to fill remaining space. Only one column should expand. - pub expand: bool, + pub(crate) expand: bool, } impl UiColumn { - pub fn new(column_type: UiColumnType) -> Self { + pub(crate) fn new(column_type: UiColumnType) -> Self { Self { width: column_type.default_width(), expand: column_type == UiColumnType::Command, @@ -910,7 +910,7 @@ impl UiColumn { } } - pub fn with_width(column_type: UiColumnType, width: u16) -> Self { + pub(crate) fn with_width(column_type: UiColumnType, width: u16) -> Self { Self { column_type, width, @@ -990,13 +990,13 @@ impl<'de> serde::Deserialize<'de> for UiColumn { /// UI-specific settings for the interactive search. #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Ui { +pub(crate) struct Ui { /// Columns to display in interactive search, from left to right. /// The indicator column (" > ") is always shown first implicitly. /// The "command" column should be last as it expands to fill remaining space. /// Can be simple strings or objects with type and width. #[serde(default = "Ui::default_columns")] - pub columns: Vec<UiColumn>, + pub(crate) columns: Vec<UiColumn>, } impl Ui { @@ -1010,7 +1010,7 @@ impl Ui { /// Validate the UI configuration. /// Returns an error if more than one column has expand = true. - pub fn validate(&self) -> Result<()> { + pub(crate) fn validate(&self) -> Result<()> { let expand_count = self.columns.iter().filter(|c| c.expand).count(); if expand_count > 1 { bail!( @@ -1031,103 +1031,103 @@ impl Default for Ui { } #[derive(Clone, Debug, Deserialize, Serialize)] -pub struct Settings { - pub data_dir: Option<String>, - pub dialect: Dialect, - pub timezone: Timezone, - pub style: Style, - pub auto_sync: bool, +pub(crate) struct Settings { + pub(crate) data_dir: Option<String>, + pub(crate) dialect: Dialect, + pub(crate) timezone: Timezone, + pub(crate) style: Style, + pub(crate) auto_sync: bool, /// The sync address for atuin. - pub sync_address: String, + pub(crate) sync_address: String, #[serde(default)] - pub sync_protocol: SyncProtocol, + pub(crate) sync_protocol: SyncProtocol, - pub sync_frequency: String, - pub db_path: String, - pub record_store_path: String, - pub key_path: String, - pub search_mode: SearchMode, - pub filter_mode: Option<FilterMode>, - pub filter_mode_shell_up_key_binding: Option<FilterMode>, - pub search_mode_shell_up_key_binding: Option<SearchMode>, - pub shell_up_key_binding: bool, - pub inline_height: u16, - pub inline_height_shell_up_key_binding: Option<u16>, - pub invert: bool, - pub show_preview: bool, - pub max_preview_height: u16, - pub show_help: bool, - pub show_tabs: bool, - pub show_numeric_shortcuts: bool, - pub auto_hide_height: u16, - pub exit_mode: ExitMode, - pub keymap_mode: KeymapMode, - pub keymap_mode_shell: KeymapMode, - pub keymap_cursor: HashMap<String, CursorStyle>, - pub word_jump_mode: WordJumpMode, - pub word_chars: String, - pub scroll_context_lines: usize, - pub history_format: String, - pub strip_trailing_whitespace: bool, - pub prefers_reduced_motion: bool, - pub store_failed: bool, - pub no_mouse: bool, + pub(crate) sync_frequency: String, + pub(crate) db_path: String, + pub(crate) record_store_path: String, + pub(crate) key_path: String, + pub(crate) search_mode: SearchMode, + pub(crate) filter_mode: Option<FilterMode>, + pub(crate) filter_mode_shell_up_key_binding: Option<FilterMode>, + pub(crate) search_mode_shell_up_key_binding: Option<SearchMode>, + pub(crate) shell_up_key_binding: bool, + pub(crate) inline_height: u16, + pub(crate) inline_height_shell_up_key_binding: Option<u16>, + pub(crate) invert: bool, + pub(crate) show_preview: bool, + pub(crate) max_preview_height: u16, + pub(crate) show_help: bool, + pub(crate) show_tabs: bool, + pub(crate) show_numeric_shortcuts: bool, + pub(crate) auto_hide_height: u16, + pub(crate) exit_mode: ExitMode, + pub(crate) keymap_mode: KeymapMode, + pub(crate) keymap_mode_shell: KeymapMode, + pub(crate) keymap_cursor: HashMap<String, CursorStyle>, + pub(crate) word_jump_mode: WordJumpMode, + pub(crate) word_chars: String, + pub(crate) scroll_context_lines: usize, + pub(crate) history_format: String, + pub(crate) strip_trailing_whitespace: bool, + pub(crate) prefers_reduced_motion: bool, + pub(crate) store_failed: bool, + pub(crate) no_mouse: bool, #[serde(with = "serde_regex", default = "RegexSet::empty", skip_serializing)] - pub history_filter: RegexSet, + pub(crate) history_filter: RegexSet, #[serde(with = "serde_regex", default = "RegexSet::empty", skip_serializing)] - pub cwd_filter: RegexSet, + pub(crate) cwd_filter: RegexSet, - pub secrets_filter: bool, - pub workspaces: bool, - pub ctrl_n_shortcuts: bool, + pub(crate) secrets_filter: bool, + pub(crate) workspaces: bool, + pub(crate) ctrl_n_shortcuts: bool, - pub network_connect_timeout: u64, - pub network_timeout: u64, - pub local_timeout: f64, - pub enter_accept: bool, - pub smart_sort: bool, - pub command_chaining: bool, + pub(crate) network_connect_timeout: u64, + pub(crate) network_timeout: u64, + pub(crate) local_timeout: f64, + pub(crate) enter_accept: bool, + pub(crate) smart_sort: bool, + pub(crate) command_chaining: bool, #[serde(default)] - pub stats: Stats, + pub(crate) stats: Stats, #[serde(default)] - pub keys: Keys, + pub(crate) keys: Keys, #[serde(default)] - pub keymap: KeymapConfig, + pub(crate) keymap: KeymapConfig, #[serde(default)] - pub preview: Preview, + pub(crate) preview: Preview, #[serde(default)] - pub daemon: Daemon, + pub(crate) daemon: Daemon, #[serde(default)] - pub search: Search, + pub(crate) search: Search, #[serde(default)] - pub theme: Theme, + pub(crate) theme: Theme, #[serde(default)] - pub ui: Ui, + pub(crate) ui: Ui, #[serde(default)] - pub tmux: Tmux, + pub(crate) tmux: Tmux, #[serde(default)] - pub logs: Logs, + pub(crate) logs: Logs, #[serde(default)] - pub meta: meta::Settings, + pub(crate) meta: meta::Settings, } impl Settings { - pub fn utc() -> Self { + pub(crate) fn utc() -> Self { Self::builder() .expect("Could not build default") .set_override("timezone", "0") @@ -1147,7 +1147,7 @@ impl Settings { // -- Meta store: lazily initialized on first access -- - pub async fn meta_store() -> Result<&'static crate::atuin_client::meta::MetaStore> { + pub(crate) async fn meta_store() -> Result<&'static crate::atuin_client::meta::MetaStore> { META_STORE .get_or_try_init(|| async { let (db_path, timeout) = META_CONFIG.get().ok_or_else(|| { @@ -1158,27 +1158,27 @@ impl Settings { .await } - pub async fn host_id() -> Result<HostId> { + pub(crate) async fn host_id() -> Result<HostId> { Self::meta_store().await?.host_id().await } - pub async fn last_sync() -> Result<OffsetDateTime> { + pub(crate) async fn last_sync() -> Result<OffsetDateTime> { Self::meta_store().await?.last_sync().await } - pub async fn save_sync_time() -> Result<()> { + pub(crate) async fn save_sync_time() -> Result<()> { Self::meta_store().await?.save_sync_time().await } - pub async fn last_version_check() -> Result<OffsetDateTime> { + pub(crate) async fn last_version_check() -> Result<OffsetDateTime> { Self::meta_store().await?.last_version_check().await } - pub async fn save_version_check_time() -> Result<()> { + pub(crate) async fn save_version_check_time() -> Result<()> { Self::meta_store().await?.save_version_check_time().await } - pub async fn should_sync(&self) -> Result<bool> { + pub(crate) async fn should_sync(&self) -> Result<bool> { if !self.auto_sync || !Self::meta_store().await?.logged_in().await? { return Ok(false); } @@ -1196,11 +1196,11 @@ impl Settings { } } - pub async fn logged_in(&self) -> Result<bool> { + pub(crate) async fn logged_in(&self) -> Result<bool> { Self::meta_store().await?.logged_in().await } - pub async fn session_token(&self) -> Result<String> { + pub(crate) async fn session_token(&self) -> Result<String> { match Self::meta_store().await?.session_token().await? { Some(token) => Ok(token), None => Err(eyre!("Tried to load session; not logged in")), @@ -1211,7 +1211,7 @@ impl Settings { /// the correct auth strategy. Also performs cleanup of mis-stored tokens /// (e.g. a CLI token incorrectly saved in the Hub session slot). #[cfg(feature = "sync")] - pub async fn resolve_sync_auth(&self) -> SyncAuth { + pub(crate) async fn resolve_sync_auth(&self) -> SyncAuth { let meta = match Self::meta_store().await { Ok(m) => m, Err(e) => { @@ -1238,11 +1238,11 @@ impl Settings { /// `AuthToken`. Callers that need to distinguish between auth states /// (e.g. to show different UI) should call `resolve_sync_auth` directly. #[cfg(feature = "sync")] - pub async fn sync_auth_token(&self) -> Result<crate::atuin_client::api_client::AuthToken> { + pub(crate) async fn sync_auth_token(&self) -> Result<crate::atuin_client::api_client::AuthToken> { self.resolve_sync_auth().await.into_auth_token() } - pub fn default_filter_mode(&self, git_root: bool) -> FilterMode { + pub(crate) fn default_filter_mode(&self, git_root: bool) -> FilterMode { self.filter_mode .filter(|x| self.search.filters.contains(x)) .or_else(|| { @@ -1259,7 +1259,7 @@ impl Settings { .unwrap_or(FilterMode::Global) } - pub fn builder() -> Result<ConfigBuilder<DefaultState>> { + pub(crate) fn builder() -> Result<ConfigBuilder<DefaultState>> { Self::builder_with_data_dir(&crate::atuin_common::utils::data_dir()) } @@ -1386,7 +1386,7 @@ impl Settings { )) } - pub fn get_config_path() -> Result<PathBuf> { + pub(crate) fn get_config_path() -> Result<PathBuf> { let config_dir = crate::atuin_common::utils::config_dir(); create_dir_all(&config_dir) @@ -1508,7 +1508,7 @@ impl Settings { /// Returns the effective value after merging defaults, config file, and /// environment — without the side-effects of full `Settings` construction /// (meta store init, path expansion, etc.). - pub fn get_config_value(key: &str) -> Result<String> { + pub(crate) fn get_config_value(key: &str) -> Result<String> { let config = Self::build_config()?; let value: config::Value = config .get(key) @@ -1567,7 +1567,7 @@ impl Settings { } } - pub fn new() -> Result<Self> { + pub(crate) fn new() -> Result<Self> { let config = Self::build_config()?; let settings: Settings = config .try_deserialize() @@ -1590,7 +1590,7 @@ impl Settings { .map_err(|e| eyre!("failed to expand path: {}", e)) } - pub fn paths_ok(&self) -> bool { + pub(crate) fn paths_ok(&self) -> bool { let paths = [ &self.db_path, &self.record_store_path, @@ -1624,7 +1624,7 @@ impl Default for Settings { /// This function is not thread-safe with concurrent calls to Settings::new() /// or other meta store initialization. Only call from tests. #[doc(hidden)] -pub fn init_meta_config_for_testing(meta_db_path: impl Into<String>, local_timeout: f64) { +pub(crate) fn init_meta_config_for_testing(meta_db_path: impl Into<String>, local_timeout: f64) { META_CONFIG.set((meta_db_path.into(), local_timeout)).ok(); } |
