diff options
Diffstat (limited to 'crates/turtle/src/atuin_daemon/client.rs')
| -rw-r--r-- | crates/turtle/src/atuin_daemon/client.rs | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/crates/turtle/src/atuin_daemon/client.rs b/crates/turtle/src/atuin_daemon/client.rs index 45ef19e9..a0a27741 100644 --- a/crates/turtle/src/atuin_daemon/client.rs +++ b/crates/turtle/src/atuin_daemon/client.rs @@ -33,12 +33,12 @@ use crate::atuin_daemon::semantic::{ semantic_client::SemanticClient as SemanticServiceClient, }; -pub struct HistoryClient { +pub(crate) struct HistoryClient { client: HistoryServiceClient<Channel>, } #[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub enum DaemonClientErrorKind { +pub(crate) enum DaemonClientErrorKind { Connect, Unavailable, Unimplemented, @@ -46,7 +46,7 @@ pub enum DaemonClientErrorKind { } #[must_use] -pub fn classify_error(error: &eyre::Report) -> DaemonClientErrorKind { +pub(crate) fn classify_error(error: &eyre::Report) -> DaemonClientErrorKind { for cause in error.chain() { if cause.downcast_ref::<tonic::transport::Error>().is_some() { return DaemonClientErrorKind::Connect; @@ -67,7 +67,7 @@ pub fn classify_error(error: &eyre::Report) -> DaemonClientErrorKind { // Wrap the grpc client impl HistoryClient { #[cfg(unix)] - pub async fn new(path: String) -> Result<Self> { + pub(crate) async fn new(path: String) -> Result<Self> { use eyre::Context; let log_path = path.clone(); @@ -92,7 +92,7 @@ impl HistoryClient { Ok(HistoryClient { client }) } - pub async fn start_history(&mut self, h: History) -> Result<StartHistoryReply> { + pub(crate) async fn start_history(&mut self, h: History) -> Result<StartHistoryReply> { let req = StartHistoryRequest { command: h.command, cwd: h.cwd, @@ -106,7 +106,7 @@ impl HistoryClient { Ok(self.client.start_history(req).await?.into_inner()) } - pub async fn end_history( + pub(crate) async fn end_history( &mut self, id: String, duration: u64, @@ -117,11 +117,11 @@ impl HistoryClient { Ok(self.client.end_history(req).await?.into_inner()) } - pub async fn status(&mut self) -> Result<StatusReply> { + pub(crate) async fn status(&mut self) -> Result<StatusReply> { Ok(self.client.status(StatusRequest {}).await?.into_inner()) } - pub async fn tail_history(&mut self) -> Result<tonic::Streaming<TailHistoryReply>> { + pub(crate) async fn tail_history(&mut self) -> Result<tonic::Streaming<TailHistoryReply>> { Ok(self .client .tail_history(TailHistoryRequest {}) @@ -129,19 +129,19 @@ impl HistoryClient { .into_inner()) } - pub async fn shutdown(&mut self) -> Result<bool> { + pub(crate) async fn shutdown(&mut self) -> Result<bool> { let resp = self.client.shutdown(ShutdownRequest {}).await?.into_inner(); Ok(resp.accepted) } } -pub struct SearchClient { +pub(crate) struct SearchClient { client: SearchServiceClient<Channel>, } impl SearchClient { #[cfg(unix)] - pub async fn new(path: String) -> Result<Self> { + pub(crate) async fn new(path: String) -> Result<Self> { let log_path = path.clone(); let channel = Endpoint::try_from("http://atuin_local_daemon:0")? .connect_with_connector(service_fn(move |_: Uri| { @@ -165,7 +165,7 @@ impl SearchClient { } #[instrument(skip_all, level = Level::TRACE, name = "daemon_client_search", fields(query = %query, query_id = query_id))] - pub async fn search( + pub(crate) async fn search( &mut self, query: String, query_id: u64, @@ -214,13 +214,13 @@ impl From<Context> for RpcSearchContext { } } -pub struct SemanticClient { +pub(crate) struct SemanticClient { client: SemanticServiceClient<Channel>, } impl SemanticClient { #[cfg(unix)] - pub async fn new(path: String) -> Result<Self> { + pub(crate) async fn new(path: String) -> Result<Self> { let log_path = path.clone(); let channel = Endpoint::try_from("http://atuin_local_daemon:0")? .connect_with_connector(service_fn(move |_: Uri| { @@ -244,11 +244,11 @@ impl SemanticClient { } #[cfg(unix)] - pub async fn from_settings(settings: &Settings) -> Result<Self> { + pub(crate) async fn from_settings(settings: &Settings) -> Result<Self> { Self::new(settings.daemon.socket_path.clone()).await } - pub async fn record_commands( + pub(crate) async fn record_commands( &mut self, captures: Vec<CommandCapture>, ) -> Result<RecordCommandsReply> { @@ -256,7 +256,7 @@ impl SemanticClient { Ok(self.client.record_commands(stream).await?.into_inner()) } - pub async fn command_output( + pub(crate) async fn command_output( &mut self, history_id: String, ranges: Vec<(i64, i64)>, @@ -280,14 +280,14 @@ impl SemanticClient { /// Client for the Control gRPC service. /// /// Used to inject events into a running daemon from external processes. -pub struct ControlClient { +pub(crate) struct ControlClient { client: ControlServiceClient<Channel>, } impl ControlClient { /// Connect to the daemon's control service. #[cfg(unix)] - pub async fn new(path: String) -> Result<Self> { + pub(crate) async fn new(path: String) -> Result<Self> { let log_path = path.clone(); let channel = Endpoint::try_from("http://atuin_local_daemon:0")? .connect_with_connector(service_fn(move |_: Uri| { @@ -312,12 +312,12 @@ impl ControlClient { /// Connect using settings. #[cfg(unix)] - pub async fn from_settings(settings: &Settings) -> Result<Self> { + pub(crate) async fn from_settings(settings: &Settings) -> Result<Self> { Self::new(settings.daemon.socket_path.clone()).await } /// Send an event to the daemon. - pub async fn send_event(&mut self, event: DaemonEvent) -> Result<()> { + pub(crate) async fn send_event(&mut self, event: DaemonEvent) -> Result<()> { let proto_event = daemon_event_to_proto(event); let request = SendEventRequest { event: Some(proto_event), @@ -377,7 +377,7 @@ fn daemon_event_to_proto( /// // Request immediate sync /// emit_event(DaemonEvent::ForceSync).await?; /// ``` -pub async fn emit_event(event: DaemonEvent) -> Result<()> { +pub(crate) async fn emit_event(event: DaemonEvent) -> Result<()> { emit_event_with_settings(event, None).await } @@ -385,7 +385,7 @@ pub async fn emit_event(event: DaemonEvent) -> Result<()> { /// /// If settings are not provided, they will be loaded from the default location. /// If the daemon isn't running, this will silently succeed. -pub async fn emit_event_with_settings( +pub(crate) async fn emit_event_with_settings( event: DaemonEvent, settings: Option<&Settings>, ) -> Result<()> { |
