use thiserror::Error;
pub type NeuralGateResult<T> = Result<T, NeuralGateError>;
#[derive(Debug, Error)]
pub enum NeuralGateError {
#[error("neural gate not initialized")]
NotInitialized,
#[error("invalid energy value: {0}")]
InvalidEnergy(f32),
#[error("hysteresis tracking error: {0}")]
HysteresisError(String),
#[error("dendritic processing error: {0}")]
DendriticError(String),
#[error("workspace broadcast error: {0}")]
WorkspaceError(String),
#[error("HDC encoding error: {0}")]
HdcEncodingError(String),
#[error("memory retrieval error: {0}")]
MemoryError(String),
#[error("configuration error: {0}")]
ConfigurationError(String),
#[error("dimension mismatch: expected {expected}, got {actual}")]
DimensionMismatch {
expected: usize,
actual: usize,
},
#[error("oscillator sync error: {0}")]
OscillatorError(String),
#[error("internal neural gate error: {0}")]
Internal(String),
}
impl NeuralGateError {
#[must_use]
pub fn dim_mismatch(expected: usize, actual: usize) -> Self {
Self::DimensionMismatch { expected, actual }
}
#[must_use]
pub fn hysteresis(msg: impl Into<String>) -> Self {
Self::HysteresisError(msg.into())
}
#[must_use]
pub fn dendritic(msg: impl Into<String>) -> Self {
Self::DendriticError(msg.into())
}
}