use std::fmt;
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum InternalViolation {
ArchetypeMetaLockPoisoned,
ComponentAlreadyPresent,
SpawnSlotOccupied,
DespawnEntityNotInArchetype,
DespawnSwapMisalignment,
DespawnMovedSlotMissingEntity,
ArchetypeEntityPositionMissing,
ComponentTypeNotRegistered,
SignatureStorageMismatch,
QueryShapeMismatch {
method: &'static str,
expected_reads: usize,
expected_writes: usize,
},
ReduceWritesNotAllowed,
ArchetypePairSameId,
PoisonedLock,
}
impl fmt::Display for InternalViolation {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
InternalViolation::ArchetypeMetaLockPoisoned => {
f.write_str("archetype meta lock poisoned")
}
InternalViolation::ComponentAlreadyPresent => {
f.write_str("insert_empty_component: component already present in archetype")
}
InternalViolation::SpawnSlotOccupied => {
f.write_str("spawn_on: target entity slot already occupied")
}
InternalViolation::DespawnEntityNotInArchetype => {
f.write_str("despawn_on: entity not in this archetype")
}
InternalViolation::DespawnSwapMisalignment => {
f.write_str("despawn_on: component swap misalignment")
}
InternalViolation::DespawnMovedSlotMissingEntity => {
f.write_str("despawn_on: moved slot missing entity; metadata out of sync")
}
InternalViolation::ArchetypeEntityPositionMissing => {
f.write_str("query: live row missing entity position metadata")
}
InternalViolation::ComponentTypeNotRegistered => {
f.write_str("from_components: component type not registered")
}
InternalViolation::SignatureStorageMismatch => {
f.write_str("from_components: archetype signature and storage mismatch")
}
InternalViolation::QueryShapeMismatch {
method,
expected_reads,
expected_writes,
} => {
write!(
f,
"{}: query must have exactly {} read(s) and {} write(s)",
method, expected_reads, expected_writes
)
}
InternalViolation::ReduceWritesNotAllowed => {
f.write_str("reduce_abstraction: writes not allowed")
}
InternalViolation::ArchetypePairSameId => f.write_str(
"get_archetype_pair_mut: source and destination archetype IDs are equal",
),
InternalViolation::PoisonedLock => {
f.write_str("a Mutex or RwLock was found in a poisoned state")
}
}
}
}
impl std::error::Error for InternalViolation {}