use std::io;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("invalid MaxMind DB database: {0}")]
InvalidDatabase(&'static str),
#[error("invalid metadata: {0}")]
InvalidMetadata(&'static str),
#[error("invalid search-tree node {0}")]
InvalidNode(u64),
#[error("invalid offset {0}")]
InvalidOffset(usize),
#[error("unsupported or invalid MMDB data type {0}")]
InvalidDataType(u8),
#[error("invalid IP version {0}")]
InvalidIpVersion(u16),
#[error("unexpected end of input")]
UnexpectedEof,
#[error("encoding error: {0}")]
EncodingError(String),
#[error("decoding error: {0}")]
DecodingError(String),
#[error("lookup did not find a matching network")]
NotFound,
#[error("resource limit exceeded: {0}")]
ResourceLimit(&'static str),
#[error(transparent)]
Io(#[from] io::Error),
#[error(transparent)]
SerdeJson(#[from] serde_json::Error),
#[error(transparent)]
AddrParse(#[from] std::net::AddrParseError),
#[error(transparent)]
IpNet(#[from] ipnet::AddrParseError),
}
pub type Result<T> = std::result::Result<T, Error>;