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
//! Protocol Buffers as a request and response body.
//!
//! Run it with the protobuf codec on and JSON off, since nothing here is JSON:
//!
//! ```text
//! cargo run -p kynos --example protobuf --no-default-features \
//! --features openapi31,macros,server,http1,protobuf
//! ```
//!
//! Two things are worth noticing:
//!
//! * **A message derives twice, and the two derives answer different
//! questions.** `prost::Message` decides the bytes; `kynos::Schema` decides
//! what the description says the bytes mean. Kynos does not generate one from
//! the other, and the reason is that it cannot: a `.proto` field number has no
//! JSON Schema meaning, and a JSON Schema constraint has no protobuf
//! encoding. Writing both is the honest cost of describing a binary codec in
//! a JSON-Schema vocabulary.
//! * **The schema describes the message, not the wire bytes.** A protobuf body
//! is not self-describing, so what goes in the operation's `content` map
//! under `application/protobuf` is the *shape* — which is what a consumer
//! generating a client from the description needs, and all a JSON Schema can
//! say about a binary encoding.
//!
//! The field numbers are what make a protobuf message forward-compatible, and
//! they are visible only in the `prost` attributes. That asymmetry is worth
//! seeing: a reader who changes `tag = "2"` has changed the wire format without
//! changing the description, and nothing here catches it — protobuf's own
//! compatibility rules are the thing that does.
use Ipv4Addr;
use ;
/// A telemetry sample, as it travels.
///
/// `Message` and `Schema` are both derived: one is the encoding, the other is
/// the contract. `Default` is required by the extractor, because decoding a
/// protobuf message starts from one and fills in the fields that arrived.
/// A batch of samples.
/// How many samples were stored.
/// Accepts a batch of samples.
///
/// Protobuf in, protobuf out. The same wrapper describes both directions, so
/// the request body and the 200 response are keyed by the same media type
/// without either being written twice.
async
async