use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum Error {
#[error("input too small: need at least {needed} bytes, got {got}")]
TooSmall {
needed: usize,
got: usize,
},
#[error("invalid XISF signature (expected `XISF0100`)")]
InvalidSignature,
#[error("XML header too large: {len} bytes exceeds the {max}-byte cap")]
HeaderTooLarge {
len: usize,
max: usize,
},
#[error("XML header is not valid UTF-8")]
Utf8(#[from] std::str::Utf8Error),
#[error("malformed XML header: {0}")]
Xml(#[from] quick_xml::Error),
#[error("malformed XML attribute: {0}")]
Attr(#[from] quick_xml::events::attributes::AttrError),
#[error("keyword `{name}` is ambiguous: it appears {count} times")]
Ambiguous {
name: String,
count: usize,
},
#[error("keyword `{name}` has no occurrence {index} ({count} present)")]
IndexOutOfRange {
name: String,
index: usize,
count: usize,
},
#[error("invalid identifier `{name}`: {reason}")]
InvalidName {
name: String,
reason: &'static str,
},
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("unsupported XISF layout for update_file: {0}")]
Unsupported(String),
}