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
59impl From<feagi_npu_neural::types::FeagiError> for BduError {
61 fn from(err: feagi_npu_neural::types::FeagiError) -> Self {
62 match &err {
63 feagi_npu_neural::types::FeagiError::InvalidArea(msg) => {
64 BduError::InvalidArea(msg.clone())
65 }
66 feagi_npu_neural::types::FeagiError::InvalidRegion(msg) => {
67 BduError::InvalidArea(msg.clone())
68 }
69 _ => BduError::Internal(err.to_string()),
70 }
71 }
72}
73
74impl From<feagi_structures::FeagiDataError> for BduError {
76 fn from(err: feagi_structures::FeagiDataError) -> Self {
77 BduError::Internal(err.to_string())
78 }
79}
80
81impl From<feagi_evolutionary::EvoError> for BduError {
83 fn from(err: feagi_evolutionary::EvoError) -> Self {
84 match &err {
85 feagi_evolutionary::EvoError::InvalidGenome(msg) => {
86 BduError::InvalidGenome(msg.clone())
87 }
88 feagi_evolutionary::EvoError::InvalidArea(msg) => BduError::InvalidArea(msg.clone()),
89 _ => BduError::Internal(err.to_string()),
90 }
91 }
92}
93
94