1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
//! The `coap-request` crate defines an interface provided by a CoAP client stack towards
//! applications that can send requests through it.
//!
//! It is the client side equivalent of the [coap-handler] crate.
//!
//! [coap-handler]: https://docs.rs/coap-handler/
//!
//! ## Usability
//!
//! This crate provides a very low-level and generic interface, which is not ideal for every-day
//! "GET me the plain text content of coap://example.com/foo" style requests. The crate
//! [coap-request-implementations] will fill the gap, just as [coap-handler-implementations] does
//! for [coap-handler].
//!
//! [coap-request-implementations]: https://docs.rs/coap-request-implementations/
//! [coap-handler-implementations]: https://docs.rs/coap-handler-implementations/
//!
//! ## Caveats
//!
//! There boundary of responsibilities for respecting protocol level requirements is not clearly
//! established yet. For example, it is unclear how the application learns special option encoding
//! rules it needs to follow given the transport, or whether other operations on the same stack
//! have concluded their operations w/rt Request-Tag processing.
//!
//! It is unclear yet whether the async functions should be Send or not (or whether distinct traits
//! are needed to cater for both cases).
use Future;
use ;
/// Interface describing a CoAP request a client wants to send
///
/// This interface requires describes the request itself, and is passed to the stack in
/// [Stack::request].
///
/// Where possible, implementers should keep the [build_request] and [process_response] async
/// functions short, ideally not having any await points at all. The interface is defined to allow
/// slow interfaces to read into the buffer already allocated by the stack without blocking the
/// remaining operations of the stack.
// Placing the type generic on the trait level instead of on the function level. Gotta see if this
// makes anything easier.
/// The CoAP stack provided by a CoAP library
///
/// Acting on this requires an exclusive reference `&mut self`. Stacks that support multiple
/// concurrent requests can allow cloning the stack, or implement this on a shared reference
/// `&self`.
///
/// In its current form, this takes no "remote address" argument, nor arguments that indicate
/// whether the request should be sent reliably. It is ecpected that stacks provide a builder like
/// this:
///
/// ```ignore
/// let wkc = stack
/// .to("coap://example.com".parse().unwrap())
/// .reliably()
/// .request(GetWellKnownCore)
/// .await
/// ```