use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Error, Debug)]
pub enum Error {
#[error("Base64 decoding error: {0}")]
Base64Decode(#[from] base64::DecodeError),
#[error("Invalid image dimensions: width={width}, height={height}")]
InvalidDimensions { width: u32, height: u32 },
#[error("Invalid image ID: {0}")]
InvalidImageId(u32),
#[error("Invalid placement ID: {0}")]
InvalidPlacementId(u32),
#[error("Invalid chunk size: {0} (must be multiple of 4, max 4096)")]
InvalidChunkSize(usize),
#[error("Missing required field: {0}")]
MissingField(&'static str),
#[error("Terminal error: {0}")]
TerminalError(String),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("UTF-8 error: {0}")]
Utf8(#[from] std::string::FromUtf8Error),
#[error("UTF-8 error: {0}")]
Utf8Error(#[from] std::str::Utf8Error),
#[error("Invalid response from terminal: {0}")]
InvalidResponse(String),
#[error("Protocol error: {0}")]
Protocol(String),
}
impl Error {
pub fn protocol(msg: impl Into<String>) -> Self {
Self::Protocol(msg.into())
}
pub fn terminal(msg: impl Into<String>) -> Self {
Self::TerminalError(msg.into())
}
}