ic_storage/runtime/
directory_model.rs1pub(super) mod leases;
3mod persistence;
4
5use crate::StableKey;
6use serde::{Deserialize, Serialize};
7
8#[derive(Clone, Copy, Debug)]
18pub struct StorageConfig {
19 pub allocations: usize,
21 pub extents: usize,
23 pub pages: u64,
25}
26
27impl Default for StorageConfig {
28 fn default() -> Self {
29 Self {
30 allocations: 4_096,
31 extents: 16_384,
32 pages: 1_048_576,
33 }
34 }
35}
36
37#[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
44pub struct AllocationId(u64);
45impl AllocationId {
46 #[must_use]
48 pub const fn get(self) -> u64 {
49 self.0
50 }
51}
52
53#[derive(Debug, thiserror::Error)]
54pub enum Error {
55 #[error("allocation page count overflow")]
57 ArithmeticOverflow,
58 #[error("directory budget exceeded")]
59 Budget,
60 #[error("invalid directory: {0}")]
61 Invalid(&'static str),
62 #[error("allocation already has a live lease")]
63 AlreadyOpen,
64 #[error("access exceeds allocation bounds")]
65 Bounds,
66 #[error("backing already has a live owner")]
67 AlreadyClaimed,
68 #[error("allocation does not exist")]
69 Missing,
70 #[error("backing growth refused")]
71 Growth,
72 #[error("directory owner is poisoned after interrupted backing IO")]
73 Poisoned,
74}