molgfx_geometry/packing/
error.rs1use molgfx_core::EntityIdError;
4use std::fmt;
5
6#[derive(Clone, Copy, PartialEq, Eq, Debug)]
8pub enum PackingError {
9 Entity(EntityIdError),
11 IndexOverflow {
13 resource: &'static str,
15 index: u64,
17 },
18}
19
20impl From<EntityIdError> for PackingError {
21 fn from(error: EntityIdError) -> Self {
22 Self::Entity(error)
23 }
24}
25
26impl fmt::Display for PackingError {
27 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
28 match self {
29 Self::Entity(error) => error.fmt(formatter),
30 Self::IndexOverflow { resource, index } => {
31 write!(
32 formatter,
33 "{resource} index {index} exceeds the GPU u32 limit"
34 )
35 }
36 }
37 }
38}
39
40impl std::error::Error for PackingError {}