use thiserror::Error;
pub type Result<T> = std::result::Result<T, TakError>;
#[derive(Error, Debug)]
pub enum TakError {
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Protocol buffer decode error: {0}")]
ProstDecode(#[from] prost::DecodeError),
#[error("Protocol buffer encode error: {0}")]
ProstEncode(#[from] prost::EncodeError),
#[error("Invalid varint encoding")]
InvalidVarint,
#[error("Connection closed")]
ConnectionClosed,
#[error("Protocol negotiation failed: {0}")]
NegotiationFailed(String),
#[error("Invalid message format: {0}")]
InvalidMessage(String),
#[error("TLS error: {0}")]
Tls(String),
#[error("Certificate error: {0}")]
Certificate(String),
}
impl From<rustls::Error> for TakError {
fn from(err: rustls::Error) -> Self {
TakError::Tls(err.to_string())
}
}