#[derive(Clone, Debug, thiserror::Error, PartialEq)]
pub enum Error {
#[error("I/O error: {0:?}")]
IoError(::std::io::ErrorKind),
#[error("Nom error: {0:?}")]
NomError(nom::error::ErrorKind),
#[error("Command was not acknowledged")]
NotAcknowledged,
#[error("Parse error")]
Parse,
#[error("Operation timed out")]
Timeout,
#[error("Unexpected response received")]
UnexpectedResponse,
#[error("Invalid address format. Expected 'xx.xx.xx'.")]
InvalidAddress,
#[error("Modem was disconnected.")]
Disconnected,
}
impl From<::std::io::Error> for Error {
fn from(e: ::std::io::Error) -> Error {
Error::IoError(e.kind())
}
}
impl From<nom::error::ErrorKind> for Error {
fn from(e: nom::error::ErrorKind) -> Error {
Error::NomError(e)
}
}
impl From<futures::channel::mpsc::SendError> for Error {
fn from(_: futures::channel::mpsc::SendError) -> Error {
Error::Disconnected
}
}