Skip to main content

procwire_client/
error.rs

1//! Error types for procwire-client.
2
3use thiserror::Error;
4
5/// Main error type for all procwire operations.
6#[derive(Debug, Error)]
7pub enum ProcwireError {
8    /// I/O error during pipe/socket operations.
9    #[error("I/O error: {0}")]
10    Io(#[from] std::io::Error),
11
12    /// JSON serialization/deserialization error (control plane only).
13    #[error("JSON error: {0}")]
14    Json(#[from] serde_json::Error),
15
16    /// MsgPack serialization/deserialization error.
17    #[error("MsgPack encode error: {0}")]
18    MsgPackEncode(#[from] rmp_serde::encode::Error),
19
20    /// MsgPack deserialization error.
21    #[error("MsgPack decode error: {0}")]
22    MsgPackDecode(#[from] rmp_serde::decode::Error),
23
24    /// Protocol error (invalid frame, wrong flags, etc.).
25    #[error("Protocol error: {0}")]
26    Protocol(String),
27
28    /// Handler not found for the given method ID.
29    #[error("Handler not found for method ID: {0}")]
30    HandlerNotFound(u16),
31
32    /// Connection closed unexpectedly.
33    #[error("Connection closed")]
34    ConnectionClosed,
35
36    /// Backpressure timeout - write buffer full.
37    #[error("Backpressure timeout")]
38    BackpressureTimeout,
39}
40
41/// Result type alias using ProcwireError.
42pub type Result<T> = std::result::Result<T, ProcwireError>;