coap-message 0.3.4

Interface to CoAP messages
Documentation
//! Implementations of our traits for various [core] types

use crate::error::RenderableOnMinimal;
use core::fmt::Debug;

impl RenderableOnMinimal for core::convert::Infallible {
    type Error<IE: RenderableOnMinimal + Debug> = core::convert::Infallible;

    fn render<M: crate::MinimalWritableMessage>(
        self,
        _: &mut M,
    ) -> Result<(), core::convert::Infallible> {
        match self {}
    }
}

impl<T: RenderableOnMinimal, E: RenderableOnMinimal> RenderableOnMinimal for Result<T, E> {
    type Error<IE: RenderableOnMinimal + Debug> = Result<T::Error<IE>, E::Error<IE>>;

    fn render<M: crate::MinimalWritableMessage>(
        self,
        msg: &mut M,
    ) -> Result<(), Self::Error<M::UnionError>> {
        Ok(match self {
            Ok(t) => t.render(msg).map_err(Ok)?,
            Err(e) => e.render(msg).map_err(Err)?,
        })
    }
}