Skip to main content

osom_lib_strings/immutable/
errors.rs

1use osom_lib_alloc::traits::AllocationError;
2use osom_lib_primitives::length::LengthError;
3use osom_lib_reprc::macros::reprc;
4
5/// Represents potential errors when working with `ImmutableString`.
6#[reprc]
7#[repr(u8)]
8#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
9pub enum ImmutableStringError {
10    /// The internal allocator returned an error.
11    AllocationError = 0,
12
13    /// Max length exceeded.
14    MaxLengthExceeded = 1,
15}
16
17impl From<AllocationError> for ImmutableStringError {
18    fn from(_: AllocationError) -> Self {
19        Self::AllocationError
20    }
21}
22
23impl From<LengthError> for ImmutableStringError {
24    fn from(_: LengthError) -> Self {
25        Self::MaxLengthExceeded
26    }
27}