use molgfx_core::EntityIdError;
use std::fmt;
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum PackingError {
Entity(EntityIdError),
IndexOverflow {
resource: &'static str,
index: u64,
},
}
impl From<EntityIdError> for PackingError {
fn from(error: EntityIdError) -> Self {
Self::Entity(error)
}
}
impl fmt::Display for PackingError {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Entity(error) => error.fmt(formatter),
Self::IndexOverflow { resource, index } => {
write!(
formatter,
"{resource} index {index} exceeds the GPU u32 limit"
)
}
}
}
}
impl std::error::Error for PackingError {}