pub type RemoteResult = std::result::Result; #[derive(Debug, thiserror::Error)] #[error("server rejected procedure with error code: {0}")] pub struct RemoteError(#[from] tonic::Status); pub type ConnectionResult = std::result::Result; #[derive(Debug, thiserror::Error)] pub enum ConnectionError { #[error("network error: {0}")] Transport(#[from] tonic::transport::Error), #[error("server rejected connection attempt: {0}")] Remote(#[from] RemoteError), } impl From for ConnectionError { fn from(value: tonic::Status) -> Self { Self::Remote(RemoteError(value)) } } pub type ControllerResult = std::result::Result; #[derive(Debug, thiserror::Error)] pub enum ControllerError { #[error("worker is already stopped")] Stopped, #[error("worker stopped before completing requested operation")] Unfulfilled, } impl From> for ControllerError { fn from(_: tokio::sync::mpsc::error::SendError) -> Self { Self::Stopped } } impl From for ControllerError { fn from(_: tokio::sync::oneshot::error::RecvError) -> Self { Self::Unfulfilled } }