use std::time::Duration;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("zmq: {0}")]
Zmq(#[from] zeromq::ZmqError),
#[error("wire: {0}")]
Wire(#[from] ts_wire::Error),
#[error("handshake timed out after {timeout:?} waiting for {stage} from engines {pending:?}")]
HandshakeTimeout {
stage: &'static str,
pending: Vec<u16>,
timeout: Duration,
},
#[error("handshake: {0}")]
Handshake(String),
#[error("invalid request: {0}")]
InvalidRequest(String),
#[error("request id `{0}` is already in flight")]
DuplicateRequestId(String),
#[error("sending to engine {engine_index} timed out after {timeout:?}")]
SendTimeout {
engine_index: u16,
timeout: Duration,
},
#[error("engines unavailable: {0}")]
Unavailable(StreamError),
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
pub enum StreamError {
#[error("an engine shut down")]
EngineDead,
#[error("output socket failed: {0}")]
Transport(String),
#[error("the client was dropped")]
ClientClosed,
}
pub type Result<T> = std::result::Result<T, Error>;