use std::{error, fmt};
use crate::aictable::Aictable;
#[derive(Debug)]
pub enum Error<T: Aictable> {
AlreadyExist(T),
MaxReached,
OutOfSpace,
}
impl<T: Aictable> fmt::Display for Error<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::AlreadyExist(id) => write!(f, "Id {:?} already exists", id),
Self::MaxReached => write!(f, "Maximum reached"),
Self::OutOfSpace => write!(f, "No more id left"),
}
}
}
impl<T: Aictable> error::Error for Error<T> {}