use crate::commands::Value;
use prost::DecodeError;
use std::io::Error;
#[derive(Debug)]
pub enum CommandError {
ServerError(String),
DecodeError(DecodeError),
WatchValueExpectationError(String),
}
#[derive(Debug)]
pub enum CommandStreamError {
ReadError(Error),
DecodeError(prost::DecodeError),
HandshakeError(Value),
CommandError(String),
}
impl From<Error> for CommandStreamError {
fn from(error: Error) -> Self {
CommandStreamError::ReadError(error)
}
}
impl From<prost::DecodeError> for CommandStreamError {
fn from(error: prost::DecodeError) -> Self {
CommandStreamError::DecodeError(error)
}
}
#[derive(Debug)]
pub enum ClientError {
CommandStreamError(CommandStreamError),
WatchStreamError(WatchStreamError),
StreamError(StreamError),
}
impl From<CommandStreamError> for ClientError {
fn from(error: CommandStreamError) -> Self {
ClientError::CommandStreamError(error)
}
}
impl From<WatchStreamError> for ClientError {
fn from(error: WatchStreamError) -> Self {
ClientError::WatchStreamError(error)
}
}
impl From<StreamError> for ClientError {
fn from(error: StreamError) -> Self {
ClientError::StreamError(error)
}
}
#[derive(Debug)]
pub enum StreamError {
IoError(Error),
DecodeError(DecodeError),
CommandError(CommandError),
}
impl From<Error> for StreamError {
fn from(error: Error) -> Self {
StreamError::IoError(error)
}
}
impl From<DecodeError> for StreamError {
fn from(error: DecodeError) -> Self {
StreamError::DecodeError(error)
}
}
impl From<CommandError> for StreamError {
fn from(error: CommandError) -> Self {
StreamError::CommandError(error)
}
}
#[derive(Debug)]
pub enum WatchStreamError {
IoError(Error),
UnexpectedResponse(Value),
StreamError(StreamError),
}
impl From<Error> for WatchStreamError {
fn from(error: Error) -> Self {
WatchStreamError::IoError(error)
}
}
impl From<StreamError> for WatchStreamError {
fn from(error: StreamError) -> Self {
WatchStreamError::StreamError(error)
}
}