pub trait WireClient: Send {
Show 16 methods
// Required methods
fn next_id(&mut self) -> String;
fn send_request<Params: Serialize + Sync>(
&mut self,
req: &JsonRpcRequest<Params>,
) -> impl Future<Output = Result<(), WireError>> + Send;
fn read_raw_message(
&mut self,
) -> impl Future<Output = Result<RawWireMessage, WireError>> + Send;
fn read_raw_message_timeout(
&mut self,
timeout: Duration,
) -> impl Future<Output = Result<RawWireMessage, WireError>> + Send;
fn send_response<T: Serialize + Send>(
&mut self,
id: &str,
result: T,
) -> impl Future<Output = Result<(), WireError>> + Send;
fn send_error(
&mut self,
id: &str,
code: i32,
message: &str,
) -> impl Future<Output = Result<(), WireError>> + Send;
fn initialize(
&mut self,
params: InitializeParams,
) -> impl Future<Output = Result<InitializeResult, WireError>> + Send;
fn is_handshake_done(&self) -> bool;
fn shutdown(self) -> impl Future<Output = Result<(), WireError>> + Send;
fn read_response<T: DeserializeOwned + Send>(
&mut self,
expected_id: &str,
) -> impl Future<Output = Result<T, WireError>> + Send;
// Provided methods
fn prompt(
&mut self,
user_input: impl Into<UserInput> + Send,
) -> impl Future<Output = Result<PromptResult, WireError>> + Send { ... }
fn start_prompt(
&mut self,
user_input: impl Into<UserInput> + Send,
) -> impl Future<Output = Result<String, WireError>> + Send { ... }
fn replay(
&mut self,
) -> impl Future<Output = Result<ReplayResult, WireError>> + Send { ... }
fn steer(
&mut self,
user_input: impl Into<UserInput> + Send,
) -> impl Future<Output = Result<SteerResult, WireError>> + Send { ... }
fn set_plan_mode(
&mut self,
enabled: bool,
) -> impl Future<Output = Result<SetPlanModeResult, WireError>> + Send { ... }
fn cancel(&mut self) -> impl Future<Output = Result<(), WireError>> + Send { ... }
}Expand description
Trait for a Kimi Wire Protocol client.
Implementations may communicate over a child process, an in-memory channel, or any other transport.
Required Methods§
Sourcefn send_request<Params: Serialize + Sync>(
&mut self,
req: &JsonRpcRequest<Params>,
) -> impl Future<Output = Result<(), WireError>> + Send
fn send_request<Params: Serialize + Sync>( &mut self, req: &JsonRpcRequest<Params>, ) -> impl Future<Output = Result<(), WireError>> + Send
Send a JSON-RPC request.
Sourcefn read_raw_message(
&mut self,
) -> impl Future<Output = Result<RawWireMessage, WireError>> + Send
fn read_raw_message( &mut self, ) -> impl Future<Output = Result<RawWireMessage, WireError>> + Send
Read the next incoming raw wire message.
Sourcefn read_raw_message_timeout(
&mut self,
timeout: Duration,
) -> impl Future<Output = Result<RawWireMessage, WireError>> + Send
fn read_raw_message_timeout( &mut self, timeout: Duration, ) -> impl Future<Output = Result<RawWireMessage, WireError>> + Send
Read the next incoming raw wire message with a timeout.
Sourcefn send_response<T: Serialize + Send>(
&mut self,
id: &str,
result: T,
) -> impl Future<Output = Result<(), WireError>> + Send
fn send_response<T: Serialize + Send>( &mut self, id: &str, result: T, ) -> impl Future<Output = Result<(), WireError>> + Send
Send a JSON-RPC success response.
Sourcefn send_error(
&mut self,
id: &str,
code: i32,
message: &str,
) -> impl Future<Output = Result<(), WireError>> + Send
fn send_error( &mut self, id: &str, code: i32, message: &str, ) -> impl Future<Output = Result<(), WireError>> + Send
Send a JSON-RPC error response.
Sourcefn initialize(
&mut self,
params: InitializeParams,
) -> impl Future<Output = Result<InitializeResult, WireError>> + Send
fn initialize( &mut self, params: InitializeParams, ) -> impl Future<Output = Result<InitializeResult, WireError>> + Send
Perform the initialize handshake.
Sourcefn is_handshake_done(&self) -> bool
fn is_handshake_done(&self) -> bool
Returns true if the initialize handshake has completed.
Sourcefn shutdown(self) -> impl Future<Output = Result<(), WireError>> + Send
fn shutdown(self) -> impl Future<Output = Result<(), WireError>> + Send
Gracefully shut down the client.
Sourcefn read_response<T: DeserializeOwned + Send>(
&mut self,
expected_id: &str,
) -> impl Future<Output = Result<T, WireError>> + Send
fn read_response<T: DeserializeOwned + Send>( &mut self, expected_id: &str, ) -> impl Future<Output = Result<T, WireError>> + Send
Wait for a response matching expected_id, buffering out-of-order
messages internally.
Provided Methods§
Sourcefn prompt(
&mut self,
user_input: impl Into<UserInput> + Send,
) -> impl Future<Output = Result<PromptResult, WireError>> + Send
fn prompt( &mut self, user_input: impl Into<UserInput> + Send, ) -> impl Future<Output = Result<PromptResult, WireError>> + Send
Send a prompt and wait for the result.
Sourcefn start_prompt(
&mut self,
user_input: impl Into<UserInput> + Send,
) -> impl Future<Output = Result<String, WireError>> + Send
fn start_prompt( &mut self, user_input: impl Into<UserInput> + Send, ) -> impl Future<Output = Result<String, WireError>> + Send
Send a prompt without waiting for the result.
Sourcefn replay(
&mut self,
) -> impl Future<Output = Result<ReplayResult, WireError>> + Send
fn replay( &mut self, ) -> impl Future<Output = Result<ReplayResult, WireError>> + Send
Replay events and requests from the current session.
Sourcefn steer(
&mut self,
user_input: impl Into<UserInput> + Send,
) -> impl Future<Output = Result<SteerResult, WireError>> + Send
fn steer( &mut self, user_input: impl Into<UserInput> + Send, ) -> impl Future<Output = Result<SteerResult, WireError>> + Send
Steer the current turn with additional user input.
Sourcefn set_plan_mode(
&mut self,
enabled: bool,
) -> impl Future<Output = Result<SetPlanModeResult, WireError>> + Send
fn set_plan_mode( &mut self, enabled: bool, ) -> impl Future<Output = Result<SetPlanModeResult, WireError>> + Send
Enable or disable plan mode.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".