coap_message_implementations/
error.rs

1use coap_message::error::RenderableOnMinimal;
2
3/// Error type for manipulation of [crate::inmemory_write] messages.
4///
5/// This is presented externally as an internal server error, but has enough structure to be useful
6/// for debugging through `dbg!()`.
7#[derive(Debug)]
8#[cfg_attr(feature = "defmt", derive(defmt::Format))]
9#[non_exhaustive]
10pub enum WriteError {
11    OutOfSequence,
12    OutOfSpace,
13}
14
15impl RenderableOnMinimal for WriteError {
16    type Error<IE: RenderableOnMinimal + core::fmt::Debug> = IE;
17    fn render<M: coap_message::MinimalWritableMessage>(
18        self,
19        msg: &mut M,
20    ) -> Result<(), Self::Error<M::UnionError>> {
21        coap_message_utils::Error::internal_server_error().render::<M>(msg)
22    }
23}
24
25impl From<core::convert::Infallible> for WriteError {
26    fn from(never: core::convert::Infallible) -> Self {
27        match never {}
28    }
29}