#[non_exhaustive]pub enum WireError {
StreamClosed,
Timeout(Duration),
SpawnFailed(String),
JsonParse(String),
JsonSerialize(String),
RequestFailed {
code: i32,
message: String,
},
UnexpectedResponseId {
expected: String,
got: String,
},
MethodNotFound(String),
UnknownMessageType(String),
InvalidPayloadType,
Io(String),
Internal(String),
}Expand description
Errors that can occur when interacting with the Kimi Wire protocol.
ADR: std::io::Error and serde_json::Error are flattened to String
variants (Io(String), JsonParse(String)) rather than preserved with
#[source]. This is a deliberate trade-off: WireError implements
Clone + PartialEq, which is required for test ergonomics (comparing
expected vs actual errors, injecting errors into mock clients). Dynamic
error types (Box<dyn std::error::Error>) are neither Clone nor
PartialEq, and #[source] would make the enum non-cloneable. Callers
still receive the full error message; the cause chain is simply collapsed
into the display string at the boundary.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
StreamClosed
The wire stream closed unexpectedly.
Timeout(Duration)
A read or write operation timed out.
SpawnFailed(String)
Failed to spawn the Kimi CLI process.
JsonParse(String)
Failed to parse a JSON message.
JsonSerialize(String)
Failed to serialize a value to JSON.
RequestFailed
The server returned a JSON-RPC error response. The server returned a JSON-RPC error response.
UnexpectedResponseId
Received a response with an unexpected request id. Received a response with an unexpected request id.
MethodNotFound(String)
The server does not support the requested method.
UnknownMessageType(String)
An unknown wire message type was received.
InvalidPayloadType
The payload was not a JSON object.
Io(String)
An I/O error occurred.
Internal(String)
A generic internal error.
Trait Implementations§
Source§impl Error for WireError
impl Error for WireError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()