async_coap/send_desc/
uri_host_path.rs1use super::*;
17use std::marker::PhantomData;
18
19impl<SD: SendDescUnicast, IC> SendDescUnicast for UriHostPath<SD, IC> {}
20impl<SD: SendDescMulticast, IC> SendDescMulticast for UriHostPath<SD, IC> {}
21
22#[derive(Debug)]
24pub struct UriHostPath<SD, IC> {
25 pub(super) inner: SD,
26 pub(super) host: Option<String>,
27 pub(super) path_and_query: RelRefBuf,
28 pub(super) phantom: PhantomData<IC>,
29}
30
31impl<SD, IC, R> SendDesc<IC, R> for UriHostPath<SD, IC>
32where
33 SD: SendDesc<IC, R>,
34 IC: InboundContext,
35 R: Send,
36{
37 send_desc_passthru_timing!(inner);
38 send_desc_passthru_handler!(inner, R);
39 send_desc_passthru_payload!(inner);
40
41 fn write_options(
42 &self,
43 msg: &mut dyn OptionInsert,
44 socket_addr: &IC::SocketAddr,
45 start: Bound<OptionNumber>,
46 end: Bound<OptionNumber>,
47 ) -> Result<(), Error> {
48 let mut unescape_buf;
51
52 write_options!((msg, socket_addr, start, end, self.inner) {
53 URI_HOST => self.host.iter(),
54 URI_PATH => {
55 unescape_buf = self.path_and_query.clone().into_unescape_buf();
56 unescape_buf.path_segments()
57 },
58 URI_QUERY => {
59 unescape_buf = self.path_and_query.clone().into_unescape_buf();
60 unescape_buf.query_items()
61 },
62 })
63 }
64}