Skip to main content

javm_cap/
error.rs

1//! Errors for cap operations.
2
3use thiserror::Error;
4
5#[derive(Debug, Error, Clone, PartialEq, Eq)]
6pub enum CapError {
7    #[error("slot index {0} out of range for cnode of size 2^{1}")]
8    SlotOutOfRange(u32, u8),
9    #[error("invalid cnode size_log {0}; must be in [0, 16]")]
10    InvalidCNodeSize(u8),
11}
12
13#[derive(Debug, Error, Clone, PartialEq, Eq)]
14pub enum OpError {
15    #[error("source slot is empty")]
16    SourceEmpty,
17    #[error("destination slot is occupied")]
18    DestinationOccupied,
19    #[error("slot {0} is pinned and cannot be mutated by generic MGMT ops")]
20    SlotPinned(u32),
21    #[error("MGMT_CNODE_SWAP must operate within a single cnode")]
22    CrossCnodeSwap,
23    #[error(transparent)]
24    Cap(#[from] CapError),
25}