async_coap/send_desc/
inspect.rs1use super::*;
17
18impl<SD: SendDescUnicast, IC> SendDescUnicast for Inspect<SD, IC> {}
19impl<SD: SendDescMulticast, IC> SendDescMulticast for Inspect<SD, IC> {}
20
21#[derive(Debug)]
23pub struct Inspect<SD, F> {
24 pub(super) inner: SD,
25 pub(super) inspect: F,
26}
27
28impl<SD, F, IC, R> SendDesc<IC, R> for Inspect<SD, F>
29where
30 SD: SendDesc<IC, R> + Send,
31 IC: InboundContext,
32 R: Send,
33 F: FnMut(&dyn InboundContext<SocketAddr = IC::SocketAddr>) + Send,
34{
35 send_desc_passthru_timing!(inner);
36 send_desc_passthru_options!(inner);
37 send_desc_passthru_payload!(inner);
38 send_desc_passthru_supports_option!(inner);
39
40 fn handler(&mut self, context: Result<&IC, Error>) -> Result<ResponseStatus<R>, Error> {
41 if let Some(context) = context.ok() {
42 (self.inspect)(context);
43 }
44 self.inner.handler(context)
45 }
46}