coap_message/
core_impl.rsuse crate::error::RenderableOnMinimal;
use crate::message::ReadableMessage;
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)?,
})
}
}
impl<T: ReadableMessage> ReadableMessage for &T {
type Code = T::Code;
type MessageOption<'a> = T::MessageOption<'a>
where
Self: 'a;
type OptionsIter<'a> = T::OptionsIter<'a>
where
Self: 'a;
fn code(&self) -> Self::Code {
(*self).code()
}
fn options(&self) -> Self::OptionsIter<'_> {
(*self).options()
}
fn payload(&self) -> &[u8] {
(*self).payload()
}
}