use std::io;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, MmapIoError>;
#[derive(Debug, Error)]
pub enum MmapIoError {
#[error("I/O error: {0}")]
Io(#[from] io::Error),
#[error("invalid access mode: {0}")]
InvalidMode(&'static str),
#[error("range out of bounds: offset={offset}, len={len}, total={total}")]
OutOfBounds {
offset: u64,
len: u64,
total: u64,
},
#[error("flush failed: {0}")]
FlushFailed(String),
#[error("resize failed: {0}")]
ResizeFailed(String),
#[error("advice failed: {0}")]
AdviceFailed(String),
#[error("lock failed: {0}")]
LockFailed(String),
#[error("unlock failed: {0}")]
UnlockFailed(String),
#[error("atomic alignment error: required={required}, offset={offset}")]
Misaligned {
required: u64,
offset: u64,
},
#[error("watch failed: {0}")]
WatchFailed(String),
}