osom_lib_arc 0.1.7

ABI-stable atomic reference counted pointers for osom_lib.
Documentation
//! Holds the definition of [`CArcError`].
use core::fmt::Display;

use osom_lib_alloc::traits::AllocationError;
use osom_lib_reprc::macros::reprc;

/// Represents possible errors when working with [`CArc`][super::carc::CArc].
#[reprc]
#[repr(u8)]
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
#[must_use]
pub enum CArcError {
    /// The underlying allocator returned an error.
    AllocationError = 0,
}

osom_lib_macros::unreachable_from_infallible!(CArcError);

impl Display for CArcError {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self {
            CArcError::AllocationError => write!(f, "CArcError::AllocationError"),
        }
    }
}

impl From<AllocationError> for CArcError {
    fn from(_: AllocationError) -> Self {
        Self::AllocationError
    }
}

/// Represents an error that occurs when the maximum number of references is exceeded.
#[reprc]
#[repr(transparent)]
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
#[must_use]
pub struct MaxReferencesExceededError;

osom_lib_macros::unreachable_from_infallible!(MaxReferencesExceededError);

impl Display for MaxReferencesExceededError {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "MaxReferencesExceededError")
    }
}