pub trait Client: Send {
// Required methods
fn request(
&mut self,
msg: ClientMessage,
) -> impl Future<Output = Result<ServerMessage>> + Send;
fn request_stream(
&mut self,
msg: ClientMessage,
) -> impl Stream<Item = Result<ServerMessage>> + Send + '_;
// Provided methods
fn send(
&mut self,
req: SendMsg,
) -> impl Future<Output = Result<SendResponse>> + Send { ... }
fn stream(
&mut self,
req: StreamMsg,
) -> impl Stream<Item = Result<Event>> + Send + '_ { ... }
fn hub(
&mut self,
req: HubMsg,
) -> impl Stream<Item = Result<Event>> + Send + '_ { ... }
fn ping(&mut self) -> impl Future<Output = Result<()>> + Send { ... }
fn subscribe_tasks(
&mut self,
) -> impl Stream<Item = Result<Event>> + Send + '_ { ... }
fn subscribe_downloads(
&mut self,
) -> impl Stream<Item = Result<Event>> + Send + '_ { ... }
fn get_config(&mut self) -> impl Future<Output = Result<String>> + Send { ... }
fn set_config(
&mut self,
config: String,
) -> impl Future<Output = Result<()>> + Send { ... }
fn service_query(
&mut self,
service: String,
query: String,
) -> impl Future<Output = Result<String>> + Send { ... }
}Expand description
Client-side protocol interface.
Implementors provide two transport primitives — request
for request-response and request_stream for
streaming operations. All typed methods are provided defaults that delegate
to these primitives.
Required Methods§
Sourcefn request(
&mut self,
msg: ClientMessage,
) -> impl Future<Output = Result<ServerMessage>> + Send
fn request( &mut self, msg: ClientMessage, ) -> impl Future<Output = Result<ServerMessage>> + Send
Send a ClientMessage and receive a single ServerMessage.
Sourcefn request_stream(
&mut self,
msg: ClientMessage,
) -> impl Stream<Item = Result<ServerMessage>> + Send + '_
fn request_stream( &mut self, msg: ClientMessage, ) -> impl Stream<Item = Result<ServerMessage>> + Send + '_
Send a ClientMessage and receive a stream of ServerMessages.
This is a raw transport primitive — the stream reads indefinitely.
Callers must detect the terminal sentinel (e.g. StreamEnd,
DownloadEnd) and stop consuming. The typed streaming methods
handle this automatically.
Provided Methods§
Sourcefn send(
&mut self,
req: SendMsg,
) -> impl Future<Output = Result<SendResponse>> + Send
fn send( &mut self, req: SendMsg, ) -> impl Future<Output = Result<SendResponse>> + Send
Send a message to an agent and receive a complete response.
Sourcefn stream(
&mut self,
req: StreamMsg,
) -> impl Stream<Item = Result<Event>> + Send + '_
fn stream( &mut self, req: StreamMsg, ) -> impl Stream<Item = Result<Event>> + Send + '_
Send a message to an agent and receive a streamed response.
Sourcefn hub(&mut self, req: HubMsg) -> impl Stream<Item = Result<Event>> + Send + '_
fn hub(&mut self, req: HubMsg) -> impl Stream<Item = Result<Event>> + Send + '_
Install or uninstall a hub package, streaming download events.
Sourcefn subscribe_tasks(&mut self) -> impl Stream<Item = Result<Event>> + Send + '_
fn subscribe_tasks(&mut self) -> impl Stream<Item = Result<Event>> + Send + '_
Subscribe to task lifecycle events.
Streams task_event::Events indefinitely until the connection closes.
Sourcefn subscribe_downloads(
&mut self,
) -> impl Stream<Item = Result<Event>> + Send + '_
fn subscribe_downloads( &mut self, ) -> impl Stream<Item = Result<Event>> + Send + '_
Subscribe to download lifecycle events.
Streams download_event::Events indefinitely until the connection closes.
Sourcefn get_config(&mut self) -> impl Future<Output = Result<String>> + Send
fn get_config(&mut self) -> impl Future<Output = Result<String>> + Send
Get the full daemon config as JSON.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.