use super::managed_key::KeyState;
use super::managed_sa::SaState;
use core::fmt;
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum KeyManagementError {
NotActive,
NotFound,
InvalidTransition { from: KeyState, to: KeyState },
}
impl fmt::Display for KeyManagementError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::NotActive => write!(f, "key not active"),
Self::NotFound => write!(f, "key not found"),
Self::InvalidTransition { from, to } => {
write!(f, "invalid key transition: {from:?} -> {to:?}")
}
}
}
}
impl core::error::Error for KeyManagementError {}
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum SaManagementError {
NotOperational,
InvalidTransition { from: SaState, to: SaState },
NotFound,
}
impl fmt::Display for SaManagementError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::NotOperational => write!(f, "SA not operational"),
Self::InvalidTransition { from, to } => {
write!(f, "invalid SA transition: {from:?} -> {to:?}")
}
Self::NotFound => write!(f, "SA not found"),
}
}
}
impl core::error::Error for SaManagementError {}