use crate::arena::PAGE_BYTES;
use crate::chunk::CHUNK_PAYLOAD;
#[derive(Clone, Copy, Debug, PartialEq, Eq, thiserror::Error)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
pub enum Error {
#[error("capacity exceeded: pool would grow past {max_bytes} bytes")]
CapacityExceeded {
max_bytes: usize,
},
#[error(
"invalid slot layout: size {size}, key_len {key_len} (require 1 <= key_len <= size <= {PAGE_BYTES})"
)]
BadSlot {
size: usize,
key_len: usize,
},
#[error("shard count must be a non-zero power of two, got {got}")]
BadShardCount {
got: usize,
},
#[error("blob of {len} bytes exceeds the configured max_blob of {max_blob} bytes")]
BlobTooLarge {
len: usize,
max_blob: usize,
},
#[error("value of {len} bytes exceeds the chunk payload of {CHUNK_PAYLOAD} bytes")]
ValueTooLarge {
len: usize,
},
#[error("corrupt image: {0}")]
Corrupt(&'static str),
}