transient_btree_index/
error.rs

1use std::{array::TryFromSliceError, num::TryFromIntError};
2
3use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, Error>;
6
7#[derive(Error, Debug)]
8#[non_exhaustive]
9pub enum Error {
10    #[error("Size of existing block (ID {block_id}) is too small to write new block. It needs {needed}.")]
11    ExistingBlockTooSmall { block_id: usize, needed: u64 },
12    #[error("The order of the tree must be at least 2, but {0} was requested.")]
13    OrderTooSmall(usize),
14    #[error("The order of the tree must is too large ({0} was requested).")]
15    OrderTooLarge(usize),
16    #[error("Requested index {idx} is larger than the number of keys in the node ({len})")]
17    KeyIndexOutOfBounds { idx: usize, len: usize },
18    #[error("When trying to insert a non-existing key, the found node block was internal and not a leaf node")]
19    InsertFoundInternalNode,
20    #[error("Splitting a node resulted in an empty child node.")]
21    EmptyChildNodeInSplit,
22    #[error("The given capacity of {capacity} was invalid.")]
23    InvalidCapacity { capacity: usize },
24    #[error("Deserialization of block failed: {0}")]
25    DeserializeBlock(String),
26    #[error(transparent)]
27    IO(#[from] std::io::Error),
28    #[error(transparent)]
29    IntConversion(#[from] TryFromIntError),
30    #[error(transparent)]
31    SliceConversion(#[from] TryFromSliceError),
32    #[error(transparent)]
33    Bincode(#[from] bincode::Error),
34    #[error("Non-existing key")]
35    NonExistingKey,
36}