#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum Component {
Comment,
Domain,
Name,
Path,
Value,
}
impl core::fmt::Display for Component {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.write_str(match self {
Self::Comment => "comment",
Self::Domain => "domain",
Self::Name => "name",
Self::Path => "path",
Self::Value => "value",
})
}
}
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[error("io error: {0}")]
Io(#[from] std::io::Error),
#[error("invalid signature: {0:?}")]
InvalidSignature([u8; 4]),
#[error("invalid page tag")]
InvalidPageTag,
#[error("invalid page end")]
InvalidPageEnd,
#[error("invalid cookie header end")]
InvalidCookieHeaderEnd,
#[error("unexpected end of input")]
UnexpectedEof,
#[error("page count too large: {0}")]
TooManyPages(u32),
#[error("cookie count too large: {0}")]
TooManyCookies(u32),
#[error("cookie {component} component too large: {size}")]
CookieTooLarge {
component: Component,
size: u32,
},
#[error("cookie total size too large: {0}")]
CookieTotalTooLarge(u32),
#[error("malformed cookie offsets")]
MalformedOffsets,
}