coap-message-implementations 0.1.7

Implementations of coap-message traits, and tools for building them
Documentation
use coap_message::error::RenderableOnMinimal;

/// Error type for manipulation of [crate::inmemory_write] messages.
///
/// This is presented externally as an internal server error, but has enough structure to be useful
/// for debugging through `dbg!()`.
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[non_exhaustive]
pub enum WriteError {
    OutOfSequence,
    OutOfSpace,
}

impl RenderableOnMinimal for WriteError {
    type Error<IE: RenderableOnMinimal + core::fmt::Debug> = IE;
    fn render<M: coap_message::MinimalWritableMessage>(
        self,
        msg: &mut M,
    ) -> Result<(), Self::Error<M::UnionError>> {
        coap_message_utils::Error::internal_server_error().render::<M>(msg)
    }
}

impl From<core::convert::Infallible> for WriteError {
    fn from(never: core::convert::Infallible) -> Self {
        match never {}
    }
}