diff options
Diffstat (limited to 'crates/daemon/src/client.rs')
| -rw-r--r-- | crates/daemon/src/client.rs | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/crates/daemon/src/client.rs b/crates/daemon/src/client.rs index 2ea7ffc5..5cccb5ff 100644 --- a/crates/daemon/src/client.rs +++ b/crates/daemon/src/client.rs @@ -9,7 +9,7 @@ use hyper_util::rt::TokioIo; use tokio::net::UnixStream; use tracing::{Level, instrument, span}; -use crate::atuin_daemon::generated; +use crate::generated; use crate::{ atuin_client::{ database::Context, @@ -41,12 +41,12 @@ use crate::{ }, }; -pub(crate) struct HistoryClient { +pub struct HistoryClient { client: HistoryServiceClient<Channel>, } #[derive(Clone, Copy, Debug, Eq, PartialEq)] -pub(crate) enum DaemonClientErrorKind { +pub enum DaemonClientErrorKind { Connect, Unavailable, Unimplemented, @@ -54,7 +54,7 @@ pub(crate) enum DaemonClientErrorKind { } #[must_use] -pub(crate) fn classify_error(error: &eyre::Report) -> DaemonClientErrorKind { +pub fn classify_error(error: &eyre::Report) -> DaemonClientErrorKind { for cause in error.chain() { if cause.downcast_ref::<tonic::transport::Error>().is_some() { return DaemonClientErrorKind::Connect; @@ -75,7 +75,7 @@ pub(crate) fn classify_error(error: &eyre::Report) -> DaemonClientErrorKind { // Wrap the grpc client impl HistoryClient { #[cfg(unix)] - pub(crate) async fn new(path: String) -> Result<Self> { + pub async fn new(path: String) -> Result<Self> { use eyre::Context; let log_path = path.clone(); @@ -100,7 +100,7 @@ impl HistoryClient { Ok(Self { client }) } - pub(crate) async fn start_history(&mut self, h: History) -> Result<StartHistoryReply> { + pub async fn start_history(&mut self, h: History) -> Result<StartHistoryReply> { let req = StartHistoryRequest { command: h.command, cwd: h.cwd, @@ -114,7 +114,7 @@ impl HistoryClient { Ok(self.client.start_history(req).await?.into_inner()) } - pub(crate) async fn end_history( + pub async fn end_history( &mut self, id: String, duration: u64, @@ -125,11 +125,11 @@ impl HistoryClient { Ok(self.client.end_history(req).await?.into_inner()) } - pub(crate) async fn status(&mut self) -> Result<StatusReply> { + pub async fn status(&mut self) -> Result<StatusReply> { Ok(self.client.status(StatusRequest {}).await?.into_inner()) } - pub(crate) async fn tail_history(&mut self) -> Result<tonic::Streaming<TailHistoryReply>> { + pub async fn tail_history(&mut self) -> Result<tonic::Streaming<TailHistoryReply>> { Ok(self .client .tail_history(TailHistoryRequest {}) @@ -137,19 +137,19 @@ impl HistoryClient { .into_inner()) } - pub(crate) async fn shutdown(&mut self) -> Result<bool> { + pub async fn shutdown(&mut self) -> Result<bool> { let resp = self.client.shutdown(ShutdownRequest {}).await?.into_inner(); Ok(resp.accepted) } } -pub(crate) struct SearchClient { +pub struct SearchClient { client: SearchServiceClient<Channel>, } impl SearchClient { #[cfg(unix)] - pub(crate) async fn new(path: String) -> Result<Self> { + pub 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| { @@ -173,7 +173,7 @@ impl SearchClient { } #[instrument(skip_all, level = Level::TRACE, name = "daemon_client_search", fields(query = %query, query_id = query_id))] - pub(crate) async fn search( + pub async fn search( &mut self, query: String, query_id: u64, @@ -222,13 +222,13 @@ impl From<Context> for RpcSearchContext { } } -pub(crate) struct SemanticClient { +pub struct SemanticClient { client: SemanticServiceClient<Channel>, } impl SemanticClient { #[cfg(unix)] - pub(crate) async fn new(path: String) -> Result<Self> { + pub 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| { @@ -252,11 +252,11 @@ impl SemanticClient { } #[cfg(unix)] - pub(crate) async fn from_settings(settings: &Settings) -> Result<Self> { + pub async fn from_settings(settings: &Settings) -> Result<Self> { Self::new(settings.daemon.socket_path.clone()).await } - pub(crate) async fn record_commands( + pub async fn record_commands( &mut self, captures: Vec<CommandCapture>, ) -> Result<RecordCommandsReply> { @@ -272,14 +272,14 @@ impl SemanticClient { /// Client for the Control gRPC service. /// /// Used to inject events into a running daemon from external processes. -pub(crate) struct ControlClient { +pub struct ControlClient { client: ControlServiceClient<Channel>, } impl ControlClient { /// Connect to the daemon's control service. #[cfg(unix)] - pub(crate) async fn new(path: String) -> Result<Self> { + pub 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| { @@ -304,12 +304,12 @@ impl ControlClient { /// Connect using settings. #[cfg(unix)] - pub(crate) async fn from_settings(settings: &Settings) -> Result<Self> { + pub async fn from_settings(settings: &Settings) -> Result<Self> { Self::new(settings.daemon.socket_path.clone()).await } /// Send an event to the daemon. - pub(crate) async fn send_event(&mut self, event: DaemonEvent) -> Result<()> { + pub async fn send_event(&mut self, event: DaemonEvent) -> Result<()> { let proto_event = daemon_event_to_proto(event); let request = SendEventRequest { event: Some(proto_event), |
