use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error<E> {
#[error(transparent)]
BinRw(#[from] binrw::Error),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
Cipher(E),
#[error("The SSH identifier was either misformatted or misprefixed")]
BadIdentifer,
#[error("Unexpected EOF while waiting for SSH identifer")]
UnexpectedEof,
}
impl<E: PartialEq> PartialEq for Error<E> {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::BinRw { .. }, Self::BinRw { .. }) => true,
(Self::Io(l0), Self::Io(r0)) => l0.kind() == r0.kind(),
(Self::Cipher(l0), Self::Cipher(r0)) => l0 == r0,
_ => core::mem::discriminant(self) == core::mem::discriminant(other),
}
}
}