use core::fmt;
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum BfsError {
StartElementNotContained,
VisitedTooSmall {
needed: usize,
actual: usize,
},
QueueTooSmall {
needed: usize,
actual: usize,
},
StartIndexOutOfBounds {
index: usize,
bound: usize,
},
NeighborIndexOutOfBounds {
index: usize,
bound: usize,
},
}
impl fmt::Display for BfsError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::StartElementNotContained => {
formatter.write_str("start element is not contained in the topology view")
}
Self::VisitedTooSmall { needed, actual } => write!(
formatter,
"visited scratch is too small: needed {needed}, got {actual}"
),
Self::QueueTooSmall { needed, actual } => write!(
formatter,
"queue scratch is too small: needed {needed}, got {actual}"
),
Self::StartIndexOutOfBounds { index, bound } => write!(
formatter,
"start element index {index} is outside element index bound {bound}"
),
Self::NeighborIndexOutOfBounds { index, bound } => write!(
formatter,
"expanded element index {index} is outside element index bound {bound}"
),
}
}
}
impl core::error::Error for BfsError {}