use std::path::PathBuf;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error)]
pub enum Error {
#[error("io error: {0}")]
Io(#[from] std::io::Error),
#[error("sqlite error: {0}")]
Sqlite(#[from] rusqlite::Error),
#[error("json error: {0}")]
Json(#[from] serde_json::Error),
#[error("toml error: {0}")]
Toml(#[from] toml::de::Error),
#[error("path not found: {0}")]
NotFound(PathBuf),
#[error("malformed packet: {0}")]
BadPacket(&'static str),
#[error("manifest corrupt: {0}")]
BadManifest(String),
#[error("invalid chunk size: {0}")]
BadChunkSize(usize),
#[error("invalid config: {0}")]
BadConfig(String),
#[error("chunk index {index} out of range (have {total})")]
OutOfRange {
index: u32,
total: u32,
},
}