1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//! Error types for the messaging module.
use crate::engine::types::ChannelID;
/// Errors that can occur during messaging registration or runtime use.
#[derive(Debug, Clone, thiserror::Error)]
pub enum MessagingError {
/// A message type with the same [`std::any::TypeId`] has already been registered.
#[error("message type already registered: {0}")]
AlreadyRegistered(&'static str),
/// Attempted to register a new message type after the registry was frozen.
#[error("cannot register after message registry is frozen")]
RegistryFrozen,
/// Attempted to construct runtime buffers before freezing the registry.
#[error("message registry must be frozen before creating a MessageBufferSet")]
RegistryNotFrozen,
/// Attempted to look up or access a message type that was never registered.
#[error("message type not registered: {0}")]
NotRegistered(&'static str),
/// A handle from one registry/runtime was used with another buffer set.
#[error("message handle belongs to a different registry")]
WrongRegistry,
/// A messaging synchronization primitive was poisoned.
#[error("messaging lock poisoned: {0}")]
LockPoisoned(&'static str),
/// Channel ID allocation exhausted the shared channel namespace.
#[error("channel ID allocation overflowed")]
ChannelAllocationOverflow,
/// The caller requested a specialisation that does not match what was
/// registered for this message type.
#[error("wrong specialisation: requested {requested} but type is registered as {actual}")]
WrongSpecialisation {
/// The specialisation the caller asked for.
requested: &'static str,
/// The specialisation the type was registered under.
actual: &'static str,
},
/// A per-tick emit capacity limit was exceeded for the given channel.
#[error("emit capacity exceeded for channel {channel_id:?}: len={len}, max={max}")]
EmitCapacityExceeded {
/// Channel whose per-tick hard cap was exceeded.
channel_id: ChannelID,
/// Number of emitted messages.
len: usize,
/// Configured hard cap.
max: usize,
},
/// Bucket registration used an invalid bucket count.
#[error("bucket config invalid: max_buckets must be greater than zero")]
InvalidBucketConfig,
/// The spatial configuration provided is invalid (e.g. non-positive
/// cell_size, or zero-area world).
#[error("spatial config invalid: cell_size={cell_size}, width={width}, height={height}")]
InvalidSpatialConfig {
/// Size of a spatial cell in world units.
cell_size: f32,
/// World width in world units.
width: f32,
/// World height in world units.
height: f32,
},
/// A bucket key was out of range for the registered `max_buckets` value.
#[error("bucket key {key} out of range (max_buckets={max})")]
BucketKeyOutOfRange {
/// The bucket key that was out of range.
key: u32,
/// The maximum number of buckets registered.
max: u32,
},
/// A message specialisation was missing its erased accessor function.
#[error("message specialisation {specialisation} is missing erased function {function}")]
MissingErasedFunction {
/// Specialisation being finalised.
specialisation: &'static str,
/// Missing erased function name.
function: &'static str,
},
/// A message finalisation invariant was violated.
#[error("message finalise invariant failed for {specialisation}: {reason}")]
FinaliseInvariant {
/// Specialisation being finalised.
specialisation: &'static str,
/// Human-readable failure reason.
reason: &'static str,
},
/// GPU message metadata does not match the payload layout.
#[cfg(feature = "messaging_gpu")]
#[error("gpu message layout invalid for {type_name}: {reason}")]
InvalidGpuMessageLayout {
/// Message type name.
type_name: &'static str,
/// Human-readable validation failure.
reason: String,
},
/// GPU message emission exceeded the registered capacity.
#[cfg(feature = "messaging_gpu")]
#[error("gpu emit capacity exceeded for {resource}: len={len}, max={max}")]
GpuEmitCapacityExceeded {
/// Resource name.
resource: String,
/// Attempted or merged message count.
len: usize,
/// Configured hard capacity.
max: usize,
},
/// GPU message finalisation reported invalid data.
#[cfg(feature = "messaging_gpu")]
#[error("gpu message finalise failed for {resource}: {reason}")]
GpuFinaliseFailed {
/// Resource name.
resource: String,
/// Human-readable failure reason.
reason: String,
},
}