feagi_brain_development/
types.rs1pub type AreaId = String;
12
13pub type Position = (u32, u32, u32);
15
16pub type Weight = u8;
18
19pub type BduResult<T> = Result<T, BduError>;
21
22#[derive(Debug, thiserror::Error)]
24pub enum BduError {
25 #[error("Invalid area: {0}")]
26 InvalidArea(String),
27
28 #[error("Invalid morphology: {0}")]
29 InvalidMorphology(String),
30
31 #[error("Invalid position: {0:?}")]
32 InvalidPosition(Position),
33
34 #[error("Dimension mismatch: expected {expected:?}, got {actual:?}")]
35 DimensionMismatch {
36 expected: (usize, usize, usize),
37 actual: (usize, usize, usize),
38 },
39
40 #[error("Out of bounds: position {pos:?} not in dimensions {dims:?}")]
41 OutOfBounds {
42 pos: Position,
43 dims: (usize, usize, usize),
44 },
45
46 #[error("Invalid genome: {0}")]
47 InvalidGenome(String),
48
49 #[error("Invalid neuron: {0}")]
50 InvalidNeuron(String),
51
52 #[error("Invalid synapse: {0}")]
53 InvalidSynapse(String),
54
55 #[error("Internal error: {0}")]
56 Internal(String),
57
58 #[error("Region IO policy violation: {0}")]
60 RegionIoPolicyViolation(String),
61}
62
63impl From<feagi_npu_neural::types::FeagiError> for BduError {
65 fn from(err: feagi_npu_neural::types::FeagiError) -> Self {
66 match &err {
67 feagi_npu_neural::types::FeagiError::InvalidArea(msg) => {
68 BduError::InvalidArea(msg.clone())
69 }
70 feagi_npu_neural::types::FeagiError::InvalidRegion(msg) => {
71 BduError::InvalidArea(msg.clone())
72 }
73 _ => BduError::Internal(err.to_string()),
74 }
75 }
76}
77
78impl From<feagi_structures::FeagiDataError> for BduError {
80 fn from(err: feagi_structures::FeagiDataError) -> Self {
81 BduError::Internal(err.to_string())
82 }
83}
84
85impl From<feagi_evolutionary::EvoError> for BduError {
87 fn from(err: feagi_evolutionary::EvoError) -> Self {
88 match &err {
89 feagi_evolutionary::EvoError::InvalidGenome(msg) => {
90 BduError::InvalidGenome(msg.clone())
91 }
92 feagi_evolutionary::EvoError::InvalidArea(msg) => BduError::InvalidArea(msg.clone()),
93 _ => BduError::Internal(err.to_string()),
94 }
95 }
96}
97
98