use std::time::Duration;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("WebSocket error: {0}")]
WebSocket(Box<tokio_tungstenite::tungstenite::Error>),
#[error("connection failed: {0}")]
ConnectionFailed(String),
#[error("unauthorized: TV rejected the connection")]
Unauthorized,
#[error("TV error on `{request}`: code {code}")]
TvError { request: String, code: String },
#[error("request timed out after {0:?}")]
Timeout(Duration),
#[error("HTTP error: {0}")]
Http(#[from] reqwest::Error),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("auth token store error: {0}")]
AuthTokenStore(Box<dyn std::error::Error + Send + Sync>),
#[error("image error: {0}")]
Image(#[from] image::ImageError),
#[error("image is {img_w}x{img_h} but TV display is {tv_w}x{tv_h}")]
IncorrectImageSize {
img_w: u32,
img_h: u32,
tv_w: u32,
tv_h: u32,
},
}