#![forbid(unsafe_code)]
use std::io;
use thiserror::Error;
pub type StorageResult<T> = Result<T, StorageError>;
#[derive(Debug, Error)]
pub enum StorageError {
#[error("io error: {0}")]
Io(#[from] io::Error),
#[cfg(not(target_arch = "wasm32"))]
#[error("mmap error: {0}")]
Mmap(#[from] mmap_io::MmapIoError),
#[error("invalid range: start {start} >= end {end}")]
InvalidRange { start: u64, end: u64 },
#[error("resource failed: {0}")]
Failed(String),
#[error("atomic-chunked tmp claimed by another writer: {0}")]
TmpClaimed(std::path::PathBuf),
#[error("processed resource is not readable before commit")]
NotReadable,
#[error("operation cancelled")]
Cancelled,
}