use osom_lib_alloc::traits::AllocationError;
use osom_lib_primitives::length::LengthError;
use osom_lib_reprc::macros::reprc;
#[reprc]
#[repr(u8)]
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum ImmutableStringError {
AllocationError = 0,
MaxLengthExceeded = 1,
}
impl From<AllocationError> for ImmutableStringError {
fn from(_: AllocationError) -> Self {
Self::AllocationError
}
}
impl From<LengthError> for ImmutableStringError {
fn from(_: LengthError) -> Self {
Self::MaxLengthExceeded
}
}
impl core::fmt::Display for ImmutableStringError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
ImmutableStringError::AllocationError => write!(f, "ImmutableStringError::AllocationError"),
ImmutableStringError::MaxLengthExceeded => write!(f, "ImmutableStringError::MaxLengthExceeded"),
}
}
}