pub(super) mod leases;
mod persistence;
use crate::StableKey;
use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Debug)]
pub struct StorageConfig {
pub allocations: usize,
pub extents: usize,
pub pages: u64,
}
impl Default for StorageConfig {
fn default() -> Self {
Self {
allocations: 4_096,
extents: 16_384,
pages: 1_048_576,
}
}
}
#[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
pub struct AllocationId(u64);
impl AllocationId {
#[must_use]
pub const fn get(self) -> u64 {
self.0
}
}
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("allocation page count overflow")]
ArithmeticOverflow,
#[error("directory budget exceeded")]
Budget,
#[error("invalid directory: {0}")]
Invalid(&'static str),
#[error("allocation already has a live lease")]
AlreadyOpen,
#[error("access exceeds allocation bounds")]
Bounds,
#[error("backing already has a live owner")]
AlreadyClaimed,
#[error("allocation does not exist")]
Missing,
#[error("backing growth refused")]
Growth,
#[error("directory owner is poisoned after interrupted backing IO")]
Poisoned,
}