Skip to main content

protosocket_rpc/
error.rs

1use std::sync::Arc;
2
3/// Result type for protosocket-rpc-client.
4pub type Result<T> = std::result::Result<T, Error>;
5
6/// Error type for protosocket-rpc-client.
7#[derive(Clone, Debug, thiserror::Error)]
8pub enum Error {
9    /// Standard IO failure
10    #[error("IO failure: {0}")]
11    IoFailure(Arc<std::io::Error>),
12    /// RPC was cancelled by the remote end
13    #[error("Rpc was cancelled remotely")]
14    CancelledRemotely,
15    /// The connection is closed, no more messages will appear
16    #[error("Connection is closed")]
17    ConnectionIsClosed,
18    /// RPC finished normally
19    #[error("Rpc finished")]
20    Finished,
21}
22
23impl From<std::io::Error> for Error {
24    fn from(value: std::io::Error) -> Self {
25        Self::IoFailure(Arc::new(value))
26    }
27}