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_pty_proxy/capture.rs | 20 +++++++-------- crates/turtle/src/atuin_pty_proxy/mod.rs | 4 +-- crates/turtle/src/atuin_pty_proxy/osc133.rs | 34 +++++++++++++------------- crates/turtle/src/atuin_pty_proxy/pty_proxy.rs | 8 +++--- 4 files changed, 33 insertions(+), 33 deletions(-) (limited to 'crates/turtle/src/atuin_pty_proxy') diff --git a/crates/turtle/src/atuin_pty_proxy/capture.rs b/crates/turtle/src/atuin_pty_proxy/capture.rs index 97ac9b8f..dbcb81fb 100644 --- a/crates/turtle/src/atuin_pty_proxy/capture.rs +++ b/crates/turtle/src/atuin_pty_proxy/capture.rs @@ -8,18 +8,18 @@ const SESSION_ID_PARAM: &str = "session_id"; const MAX_OUTPUT_CAPTURE_BYTES: usize = 1024 * 1024; #[derive(Debug, Clone, PartialEq, Eq)] -pub struct CommandCapture { - pub prompt: String, - pub command: String, - pub output: String, - pub exit_code: Option, - pub history_id: Option, - pub session_id: Option, - pub output_truncated: bool, - pub output_observed_bytes: u64, +pub(crate) struct CommandCapture { + pub(crate) prompt: String, + pub(crate) command: String, + pub(crate) output: String, + pub(crate) exit_code: Option, + pub(crate) history_id: Option, + pub(crate) session_id: Option, + pub(crate) output_truncated: bool, + pub(crate) output_observed_bytes: u64, } -pub type CommandCaptureSink = Box; +pub(crate) type CommandCaptureSink = Box; #[derive(Default)] struct CaptureBuffers { diff --git a/crates/turtle/src/atuin_pty_proxy/mod.rs b/crates/turtle/src/atuin_pty_proxy/mod.rs index 612943fa..e1d01c83 100644 --- a/crates/turtle/src/atuin_pty_proxy/mod.rs +++ b/crates/turtle/src/atuin_pty_proxy/mod.rs @@ -12,6 +12,6 @@ mod runtime; mod screen; #[cfg(unix)] -pub use capture::{CommandCapture, CommandCaptureSink}; +pub(crate) use capture::{CommandCapture, CommandCaptureSink}; #[cfg(unix)] -pub use pty_proxy::PtyProxy; +pub(crate) use pty_proxy::PtyProxy; diff --git a/crates/turtle/src/atuin_pty_proxy/osc133.rs b/crates/turtle/src/atuin_pty_proxy/osc133.rs index 5b70f0aa..d79166a6 100644 --- a/crates/turtle/src/atuin_pty_proxy/osc133.rs +++ b/crates/turtle/src/atuin_pty_proxy/osc133.rs @@ -25,7 +25,7 @@ /// Events emitted when an OSC 133 marker is detected. #[derive(Debug, Clone, PartialEq, Eq)] -pub enum Event { +pub(crate) enum Event { /// `ESC ] 133 ; A ST` — the shell is about to display its prompt. PromptStart, /// `ESC ] 133 ; B ST` — the prompt has ended; the user may type a command. @@ -41,7 +41,7 @@ pub enum Event { /// Parameters attached to an OSC 133 marker. #[derive(Debug, Default, Clone, PartialEq, Eq)] -pub struct Params { +pub(crate) struct Params { items: Vec, } @@ -49,13 +49,13 @@ impl Params { /// Iterate over all marker parameters in order. #[cfg(test)] #[inline] - pub fn iter(&self) -> impl Iterator { + pub(crate) fn iter(&self) -> impl Iterator { self.items.iter() } /// Return the value for the first `key=value` parameter with this key. #[inline] - pub fn get(&self, key: &str) -> Option<&str> { + pub(crate) fn get(&self, key: &str) -> Option<&str> { self.items.iter().find_map(|item| match item { Param::KeyValue { key: item_key, @@ -68,7 +68,7 @@ impl Params { /// A single OSC 133 marker parameter. #[derive(Debug, Clone, PartialEq, Eq)] -pub enum Param { +pub(crate) enum Param { /// A positional parameter without an equals sign. Value(String), /// A `key=value` parameter. @@ -77,29 +77,29 @@ pub enum Param { /// An OSC 133 event with its position in the most recent input chunk. #[derive(Debug, Clone, PartialEq, Eq)] -pub struct LocatedEvent { +pub(crate) struct LocatedEvent { /// The OSC 133 event that was parsed. - pub event: Event, + pub(crate) event: Event, /// Offset where this marker starts in the current chunk. /// /// If a marker started in an earlier [`Parser::push_located`] call, this is /// `0` in the chunk that completed the marker. - pub start_offset: usize, + pub(crate) start_offset: usize, /// Offset immediately after this marker's terminator in the current chunk. /// /// If a marker spans multiple [`Parser::push_located`] calls, this is still /// the offset in the chunk that completed the marker. - pub offset: usize, + pub(crate) offset: usize, /// The semantic zone after applying this event. - pub zone: Zone, + pub(crate) zone: Zone, /// Metadata parameters attached to this marker. - pub params: Params, + pub(crate) params: Params, } /// The current semantic zone as determined by the most recent OSC 133 marker. #[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] #[expect(dead_code)] -pub enum Zone { +pub(crate) enum Zone { /// No marker seen yet, or after a `D` marker (between commands). #[default] Unknown, @@ -149,7 +149,7 @@ enum State { /// OSC 133 markers and reports [`Event`]s through a caller-supplied callback /// without modifying the data. It can sit transparently between a PTY reader /// and stdout. -pub struct Parser { +pub(crate) struct Parser { state: State, zone: Zone, sequence_start: Option, @@ -166,7 +166,7 @@ impl Default for Parser { impl Parser { /// Create a new parser in the initial (ground / unknown-zone) state. #[inline] - pub fn new() -> Self { + pub(crate) fn new() -> Self { Self { state: State::Ground, zone: Zone::Unknown, @@ -179,7 +179,7 @@ impl Parser { /// The current semantic zone based on markers seen so far. #[inline] #[expect(dead_code)] - pub fn zone(&self) -> Zone { + pub(crate) fn zone(&self) -> Zone { self.zone } @@ -197,7 +197,7 @@ impl Parser { /// caller — this method only *observes* the stream. #[cfg(test)] #[inline] - pub fn push(&mut self, data: &[u8], mut on_event: impl FnMut(Event)) { + pub(crate) fn push(&mut self, data: &[u8], mut on_event: impl FnMut(Event)) { self.push_located(data, |located| on_event(located.event)); } @@ -208,7 +208,7 @@ impl Parser { /// it suitable for callers that need to split the original chunk at marker /// boundaries. #[inline] - pub fn push_located(&mut self, data: &[u8], mut on_event: impl FnMut(LocatedEvent)) { + pub(crate) fn push_located(&mut self, data: &[u8], mut on_event: impl FnMut(LocatedEvent)) { self.sequence_start = (self.state != State::Ground).then_some(0); for (offset, &byte) in data.iter().enumerate() { diff --git a/crates/turtle/src/atuin_pty_proxy/pty_proxy.rs b/crates/turtle/src/atuin_pty_proxy/pty_proxy.rs index 8dde6f53..70a53318 100644 --- a/crates/turtle/src/atuin_pty_proxy/pty_proxy.rs +++ b/crates/turtle/src/atuin_pty_proxy/pty_proxy.rs @@ -3,7 +3,7 @@ use clap::{Args, Subcommand, ValueEnum}; use crate::atuin_pty_proxy::{CommandCaptureSink, runtime}; #[derive(Args, Debug)] -pub struct PtyProxy { +pub(crate) struct PtyProxy { /// Highlight OSC 133 prompt, input, output, and exit-code regions #[arg(long)] debug_osc133: bool, @@ -13,13 +13,13 @@ pub struct PtyProxy { } #[derive(Subcommand, Debug)] -pub enum Cmd { +pub(crate) enum Cmd { /// Print shell code to initialize atuin pty-proxy on shell startup Init(Init), } #[derive(Args, Debug)] -pub struct Init { +pub(crate) struct Init { /// Shell to generate init for. If omitted, attempt auto-detection #[arg(value_enum)] shell: Option, @@ -54,7 +54,7 @@ impl RuntimeOptions { } impl PtyProxy { - pub fn run(self, command_capture_sink: Option) { + pub(crate) fn run(self, command_capture_sink: Option) { match self.cmd { Some(Cmd::Init(init)) => { if let Err(err) = init.run() { -- cgit v1.3.1