#[derive(Debug, thiserror::Error)]
pub enum SlotBusError {
#[error("shared memory error: {0}")]
SharedMemory(String),
#[error("event error: {0}")]
Event(String),
#[error("invalid control region: {0}")]
InvalidRegion(String),
#[error("no free slots available (all {0} slots in use)")]
NoFreeSlots(usize),
#[error("serialization error: {0}")]
Serialization(String),
#[error("request timed out after {0}ms")]
Timeout(u32),
#[error("unexpected slot state: expected {expected}, found {found}")]
BadSlotState { expected: u32, found: u32 },
#[error("CAS failed on slot {slot}: expected {expected}, found {found}")]
CasFailed {
slot: usize,
expected: u32,
found: u32,
},
#[error("receive loop stopped")]
ReceiveLoopStopped,
}
impl From<postcard::Error> for SlotBusError {
fn from(e: postcard::Error) -> Self {
Self::Serialization(e.to_string())
}
}