1#![allow(clippy::needless_lifetimes)]
9use super::*;
10pub(crate) mod metrics;
11pub mod api {
12 #"]
13 use super::*;
14 #[allow(unused_imports)]
15 use crate::event::metrics::aggregate;
16 pub use traits::Subscriber;
17 #[derive(Clone, Debug)]
18 #[non_exhaustive]
19 pub struct ConnectionMeta {
20 pub endpoint_type: EndpointType,
21 pub id: u64,
22 pub timestamp: crate::event::Timestamp,
23 }
24 #[cfg(any(test, feature = "testing"))]
25 impl crate::event::snapshot::Fmt for ConnectionMeta {
26 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
27 let mut fmt = fmt.debug_struct("ConnectionMeta");
28 fmt.field("endpoint_type", &self.endpoint_type);
29 fmt.field("id", &self.id);
30 fmt.field("timestamp", &self.timestamp);
31 fmt.finish()
32 }
33 }
34 #[derive(Clone, Debug)]
35 #[non_exhaustive]
36 pub struct EndpointMeta {
37 pub endpoint_type: EndpointType,
38 pub timestamp: crate::event::Timestamp,
39 }
40 #[cfg(any(test, feature = "testing"))]
41 impl crate::event::snapshot::Fmt for EndpointMeta {
42 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
43 let mut fmt = fmt.debug_struct("EndpointMeta");
44 fmt.field("endpoint_type", &self.endpoint_type);
45 fmt.field("timestamp", &self.timestamp);
46 fmt.finish()
47 }
48 }
49 #[derive(Clone, Debug)]
50 #[non_exhaustive]
51 pub struct ConnectionInfo {}
52 #[cfg(any(test, feature = "testing"))]
53 impl crate::event::snapshot::Fmt for ConnectionInfo {
54 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
55 let mut fmt = fmt.debug_struct("ConnectionInfo");
56 fmt.finish()
57 }
58 }
59 #[derive(Clone, Debug)]
60 #[non_exhaustive]
61 pub struct TransportParameters<'a> {
62 pub original_destination_connection_id: Option<ConnectionId<'a>>,
63 pub initial_source_connection_id: Option<ConnectionId<'a>>,
64 pub retry_source_connection_id: Option<ConnectionId<'a>>,
65 pub stateless_reset_token: Option<&'a [u8]>,
66 pub preferred_address: Option<PreferredAddress<'a>>,
67 pub migration_support: bool,
68 pub max_idle_timeout: Duration,
69 pub ack_delay_exponent: u8,
70 pub max_ack_delay: Duration,
71 pub max_udp_payload_size: u64,
72 pub active_connection_id_limit: u64,
73 pub initial_max_stream_data_bidi_local: u64,
74 pub initial_max_stream_data_bidi_remote: u64,
75 pub initial_max_stream_data_uni: u64,
76 pub initial_max_streams_bidi: u64,
77 pub initial_max_streams_uni: u64,
78 pub max_datagram_frame_size: u64,
79 pub dc_supported_versions: &'a [u32],
80 }
81 #[cfg(any(test, feature = "testing"))]
82 impl<'a> crate::event::snapshot::Fmt for TransportParameters<'a> {
83 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
84 let mut fmt = fmt.debug_struct("TransportParameters");
85 fmt.field(
86 "original_destination_connection_id",
87 &self.original_destination_connection_id,
88 );
89 fmt.field(
90 "initial_source_connection_id",
91 &self.initial_source_connection_id,
92 );
93 fmt.field(
94 "retry_source_connection_id",
95 &self.retry_source_connection_id,
96 );
97 fmt.field("stateless_reset_token", &self.stateless_reset_token);
98 fmt.field("preferred_address", &self.preferred_address);
99 fmt.field("migration_support", &self.migration_support);
100 fmt.field("max_idle_timeout", &self.max_idle_timeout);
101 fmt.field("ack_delay_exponent", &self.ack_delay_exponent);
102 fmt.field("max_ack_delay", &self.max_ack_delay);
103 fmt.field("max_udp_payload_size", &self.max_udp_payload_size);
104 fmt.field(
105 "active_connection_id_limit",
106 &self.active_connection_id_limit,
107 );
108 fmt.field(
109 "initial_max_stream_data_bidi_local",
110 &self.initial_max_stream_data_bidi_local,
111 );
112 fmt.field(
113 "initial_max_stream_data_bidi_remote",
114 &self.initial_max_stream_data_bidi_remote,
115 );
116 fmt.field(
117 "initial_max_stream_data_uni",
118 &self.initial_max_stream_data_uni,
119 );
120 fmt.field("initial_max_streams_bidi", &self.initial_max_streams_bidi);
121 fmt.field("initial_max_streams_uni", &self.initial_max_streams_uni);
122 fmt.field("max_datagram_frame_size", &self.max_datagram_frame_size);
123 fmt.field("dc_supported_versions", &self.dc_supported_versions);
124 fmt.finish()
125 }
126 }
127 #[derive(Clone, Debug)]
128 #[non_exhaustive]
129 pub struct PreferredAddress<'a> {
130 pub ipv4_address: Option<SocketAddress<'a>>,
131 pub ipv6_address: Option<SocketAddress<'a>>,
132 pub connection_id: ConnectionId<'a>,
133 pub stateless_reset_token: &'a [u8],
134 }
135 #[cfg(any(test, feature = "testing"))]
136 impl<'a> crate::event::snapshot::Fmt for PreferredAddress<'a> {
137 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
138 let mut fmt = fmt.debug_struct("PreferredAddress");
139 fmt.field("ipv4_address", &self.ipv4_address);
140 fmt.field("ipv6_address", &self.ipv6_address);
141 fmt.field("connection_id", &self.connection_id);
142 fmt.field("stateless_reset_token", &self.stateless_reset_token);
143 fmt.finish()
144 }
145 }
146 #[derive(Clone, Debug)]
147 #[non_exhaustive]
148 pub struct Path<'a> {
149 pub local_addr: SocketAddress<'a>,
150 pub local_cid: ConnectionId<'a>,
151 pub remote_addr: SocketAddress<'a>,
152 pub remote_cid: ConnectionId<'a>,
153 pub id: u64,
154 pub is_active: bool,
155 }
156 #[cfg(any(test, feature = "testing"))]
157 impl<'a> crate::event::snapshot::Fmt for Path<'a> {
158 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
159 let mut fmt = fmt.debug_struct("Path");
160 fmt.field("local_addr", &self.local_addr);
161 fmt.field("local_cid", &self.local_cid);
162 fmt.field("remote_addr", &self.remote_addr);
163 fmt.field("remote_cid", &self.remote_cid);
164 fmt.field("id", &self.id);
165 fmt.field("is_active", &self.is_active);
166 fmt.finish()
167 }
168 }
169 #[non_exhaustive]
170 #[derive(Clone)]
171 pub struct ConnectionId<'a> {
172 pub bytes: &'a [u8],
173 }
174 #[cfg(any(test, feature = "testing"))]
175 impl<'a> crate::event::snapshot::Fmt for ConnectionId<'a> {
176 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
177 let mut fmt = fmt.debug_struct("ConnectionId");
178 fmt.field("bytes", &self.bytes);
179 fmt.finish()
180 }
181 }
182 #[derive(Clone, Debug)]
183 #[non_exhaustive]
184 pub struct EcnCounts {
185 #[doc = " A variable-length integer representing the total number of packets"]
186 #[doc = " received with the ECT(0) codepoint."]
187 pub ect_0_count: u64,
188 #[doc = " A variable-length integer representing the total number of packets"]
189 #[doc = " received with the ECT(1) codepoint."]
190 pub ect_1_count: u64,
191 #[doc = " A variable-length integer representing the total number of packets"]
192 #[doc = " received with the CE codepoint."]
193 pub ce_count: u64,
194 }
195 #[cfg(any(test, feature = "testing"))]
196 impl crate::event::snapshot::Fmt for EcnCounts {
197 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
198 let mut fmt = fmt.debug_struct("EcnCounts");
199 fmt.field("ect_0_count", &self.ect_0_count);
200 fmt.field("ect_1_count", &self.ect_1_count);
201 fmt.field("ce_count", &self.ce_count);
202 fmt.finish()
203 }
204 }
205 #[non_exhaustive]
206 #[derive(Clone)]
207 pub struct ConnectionCloseFrame<'a> {
208 pub error_code: u64,
209 pub frame_type: Option<u64>,
210 pub reason: Option<&'a [u8]>,
211 }
212 #[cfg(any(test, feature = "testing"))]
213 impl<'a> crate::event::snapshot::Fmt for ConnectionCloseFrame<'a> {
214 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
215 let mut fmt = fmt.debug_struct("ConnectionCloseFrame");
216 fmt.field("error_code", &self.error_code);
217 fmt.field("frame_type", &self.frame_type);
218 fmt.field("reason", &self.reason);
219 fmt.finish()
220 }
221 }
222 #[derive(Clone, Debug)]
223 #[non_exhaustive]
224 pub struct MtuConfig {
225 pub initial_mtu: u16,
226 pub base_mtu: u16,
227 pub max_mtu: u16,
228 }
229 #[cfg(any(test, feature = "testing"))]
230 impl crate::event::snapshot::Fmt for MtuConfig {
231 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
232 let mut fmt = fmt.debug_struct("MtuConfig");
233 fmt.field("initial_mtu", &self.initial_mtu);
234 fmt.field("base_mtu", &self.base_mtu);
235 fmt.field("max_mtu", &self.max_mtu);
236 fmt.finish()
237 }
238 }
239 #[derive(Clone, Debug)]
240 #[non_exhaustive]
241 #[doc = " A bandwidth delivery rate estimate with associated metadata"]
242 pub struct RateSample {
243 #[doc = " The length of the sampling interval"]
244 pub interval: Duration,
245 #[doc = " The amount of data in bytes marked as delivered over the sampling interval"]
246 pub delivered_bytes: u64,
247 #[doc = " The amount of data in bytes marked as lost over the sampling interval"]
248 pub lost_bytes: u64,
249 #[doc = " The number of packets marked as explicit congestion experienced over the sampling interval"]
250 pub ecn_ce_count: u64,
251 #[doc = " PacketInfo::is_app_limited from the most recent acknowledged packet"]
252 pub is_app_limited: bool,
253 #[doc = " PacketInfo::delivered_bytes from the most recent acknowledged packet"]
254 pub prior_delivered_bytes: u64,
255 #[doc = " PacketInfo::bytes_in_flight from the most recent acknowledged packet"]
256 pub bytes_in_flight: u32,
257 #[doc = " PacketInfo::lost_bytes from the most recent acknowledged packet"]
258 pub prior_lost_bytes: u64,
259 #[doc = " PacketInfo::ecn_ce_count from the most recent acknowledged packet"]
260 pub prior_ecn_ce_count: u64,
261 #[doc = " The delivery rate for this rate sample"]
262 pub delivery_rate_bytes_per_second: u64,
263 }
264 #[cfg(any(test, feature = "testing"))]
265 impl crate::event::snapshot::Fmt for RateSample {
266 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
267 let mut fmt = fmt.debug_struct("RateSample");
268 fmt.field("interval", &self.interval);
269 fmt.field("delivered_bytes", &self.delivered_bytes);
270 fmt.field("lost_bytes", &self.lost_bytes);
271 fmt.field("ecn_ce_count", &self.ecn_ce_count);
272 fmt.field("is_app_limited", &self.is_app_limited);
273 fmt.field("prior_delivered_bytes", &self.prior_delivered_bytes);
274 fmt.field("bytes_in_flight", &self.bytes_in_flight);
275 fmt.field("prior_lost_bytes", &self.prior_lost_bytes);
276 fmt.field("prior_ecn_ce_count", &self.prior_ecn_ce_count);
277 fmt.field(
278 "delivery_rate_bytes_per_second",
279 &self.delivery_rate_bytes_per_second,
280 );
281 fmt.finish()
282 }
283 }
284 #[non_exhaustive]
285 #[derive(Clone)]
286 pub enum SocketAddress<'a> {
287 #[non_exhaustive]
288 IpV4 { ip: &'a [u8; 4], port: u16 },
289 #[non_exhaustive]
290 IpV6 { ip: &'a [u8; 16], port: u16 },
291 }
292 impl<'a> aggregate::AsVariant for SocketAddress<'a> {
293 const VARIANTS: &'static [aggregate::info::Variant] = &[
294 aggregate::info::variant::Builder {
295 name: aggregate::info::Str::new("IP_V4\0"),
296 id: 0usize,
297 }
298 .build(),
299 aggregate::info::variant::Builder {
300 name: aggregate::info::Str::new("IP_V6\0"),
301 id: 1usize,
302 }
303 .build(),
304 ];
305 #[inline]
306 fn variant_idx(&self) -> usize {
307 match self {
308 Self::IpV4 { .. } => 0usize,
309 Self::IpV6 { .. } => 1usize,
310 }
311 }
312 }
313 #[derive(Clone, Debug)]
314 #[non_exhaustive]
315 pub enum DuplicatePacketError {
316 #[non_exhaustive]
317 #[doc = " The packet number was already received and is a duplicate."]
318 Duplicate {},
319 #[non_exhaustive]
320 #[doc = " The received packet number was outside the range of tracked packet numbers."]
321 #[doc = ""]
322 #[doc = " This can happen when packets are heavily delayed or reordered. Currently, the maximum"]
323 #[doc = " amount of reordering is limited to 128 packets. For example, if packet number `142`"]
324 #[doc = " is received, the allowed range would be limited to `14-142`. If an endpoint received"]
325 #[doc = " packet `< 14`, it would trigger this event."]
326 TooOld {},
327 }
328 impl aggregate::AsVariant for DuplicatePacketError {
329 const VARIANTS: &'static [aggregate::info::Variant] = &[
330 aggregate::info::variant::Builder {
331 name: aggregate::info::Str::new("DUPLICATE\0"),
332 id: 0usize,
333 }
334 .build(),
335 aggregate::info::variant::Builder {
336 name: aggregate::info::Str::new("TOO_OLD\0"),
337 id: 1usize,
338 }
339 .build(),
340 ];
341 #[inline]
342 fn variant_idx(&self) -> usize {
343 match self {
344 Self::Duplicate { .. } => 0usize,
345 Self::TooOld { .. } => 1usize,
346 }
347 }
348 }
349 #[derive(Clone, Debug)]
350 #[non_exhaustive]
351 pub enum Frame {
352 #[non_exhaustive]
353 Padding {},
354 #[non_exhaustive]
355 Ping {},
356 #[non_exhaustive]
357 Ack {
358 ecn_counts: Option<EcnCounts>,
359 largest_acknowledged: u64,
360 ack_range_count: u64,
361 },
362 #[non_exhaustive]
363 ResetStream {
364 id: u64,
365 error_code: u64,
366 final_size: u64,
367 },
368 #[non_exhaustive]
369 StopSending { id: u64, error_code: u64 },
370 #[non_exhaustive]
371 Crypto { offset: u64, len: u16 },
372 #[non_exhaustive]
373 NewToken {},
374 #[non_exhaustive]
375 Stream {
376 id: u64,
377 offset: u64,
378 len: u16,
379 is_fin: bool,
380 },
381 #[non_exhaustive]
382 MaxData { value: u64 },
383 #[non_exhaustive]
384 MaxStreamData {
385 stream_type: StreamType,
386 id: u64,
387 value: u64,
388 },
389 #[non_exhaustive]
390 MaxStreams { stream_type: StreamType, value: u64 },
391 #[non_exhaustive]
392 DataBlocked { data_limit: u64 },
393 #[non_exhaustive]
394 StreamDataBlocked {
395 stream_id: u64,
396 stream_data_limit: u64,
397 },
398 #[non_exhaustive]
399 StreamsBlocked {
400 stream_type: StreamType,
401 stream_limit: u64,
402 },
403 #[non_exhaustive]
404 NewConnectionId {
405 sequence_number: u64,
406 retire_prior_to: u64,
407 },
408 #[non_exhaustive]
409 RetireConnectionId {},
410 #[non_exhaustive]
411 PathChallenge {},
412 #[non_exhaustive]
413 PathResponse {},
414 #[non_exhaustive]
415 ConnectionClose {},
416 #[non_exhaustive]
417 HandshakeDone {},
418 #[non_exhaustive]
419 Datagram { len: u16 },
420 #[non_exhaustive]
421 DcStatelessResetTokens {},
422 }
423 impl aggregate::AsVariant for Frame {
424 const VARIANTS: &'static [aggregate::info::Variant] = &[
425 aggregate::info::variant::Builder {
426 name: aggregate::info::Str::new("PADDING\0"),
427 id: 0usize,
428 }
429 .build(),
430 aggregate::info::variant::Builder {
431 name: aggregate::info::Str::new("PING\0"),
432 id: 1usize,
433 }
434 .build(),
435 aggregate::info::variant::Builder {
436 name: aggregate::info::Str::new("ACK\0"),
437 id: 2usize,
438 }
439 .build(),
440 aggregate::info::variant::Builder {
441 name: aggregate::info::Str::new("RESET_STREAM\0"),
442 id: 3usize,
443 }
444 .build(),
445 aggregate::info::variant::Builder {
446 name: aggregate::info::Str::new("STOP_SENDING\0"),
447 id: 4usize,
448 }
449 .build(),
450 aggregate::info::variant::Builder {
451 name: aggregate::info::Str::new("CRYPTO\0"),
452 id: 5usize,
453 }
454 .build(),
455 aggregate::info::variant::Builder {
456 name: aggregate::info::Str::new("NEW_TOKEN\0"),
457 id: 6usize,
458 }
459 .build(),
460 aggregate::info::variant::Builder {
461 name: aggregate::info::Str::new("STREAM\0"),
462 id: 7usize,
463 }
464 .build(),
465 aggregate::info::variant::Builder {
466 name: aggregate::info::Str::new("MAX_DATA\0"),
467 id: 8usize,
468 }
469 .build(),
470 aggregate::info::variant::Builder {
471 name: aggregate::info::Str::new("MAX_STREAM_DATA\0"),
472 id: 9usize,
473 }
474 .build(),
475 aggregate::info::variant::Builder {
476 name: aggregate::info::Str::new("MAX_STREAMS\0"),
477 id: 10usize,
478 }
479 .build(),
480 aggregate::info::variant::Builder {
481 name: aggregate::info::Str::new("DATA_BLOCKED\0"),
482 id: 11usize,
483 }
484 .build(),
485 aggregate::info::variant::Builder {
486 name: aggregate::info::Str::new("STREAM_DATA_BLOCKED\0"),
487 id: 12usize,
488 }
489 .build(),
490 aggregate::info::variant::Builder {
491 name: aggregate::info::Str::new("STREAMS_BLOCKED\0"),
492 id: 13usize,
493 }
494 .build(),
495 aggregate::info::variant::Builder {
496 name: aggregate::info::Str::new("NEW_CONNECTION_ID\0"),
497 id: 14usize,
498 }
499 .build(),
500 aggregate::info::variant::Builder {
501 name: aggregate::info::Str::new("RETIRE_CONNECTION_ID\0"),
502 id: 15usize,
503 }
504 .build(),
505 aggregate::info::variant::Builder {
506 name: aggregate::info::Str::new("PATH_CHALLENGE\0"),
507 id: 16usize,
508 }
509 .build(),
510 aggregate::info::variant::Builder {
511 name: aggregate::info::Str::new("PATH_RESPONSE\0"),
512 id: 17usize,
513 }
514 .build(),
515 aggregate::info::variant::Builder {
516 name: aggregate::info::Str::new("CONNECTION_CLOSE\0"),
517 id: 18usize,
518 }
519 .build(),
520 aggregate::info::variant::Builder {
521 name: aggregate::info::Str::new("HANDSHAKE_DONE\0"),
522 id: 19usize,
523 }
524 .build(),
525 aggregate::info::variant::Builder {
526 name: aggregate::info::Str::new("DATAGRAM\0"),
527 id: 20usize,
528 }
529 .build(),
530 aggregate::info::variant::Builder {
531 name: aggregate::info::Str::new("DC_STATELESS_RESET_TOKENS\0"),
532 id: 21usize,
533 }
534 .build(),
535 ];
536 #[inline]
537 fn variant_idx(&self) -> usize {
538 match self {
539 Self::Padding { .. } => 0usize,
540 Self::Ping { .. } => 1usize,
541 Self::Ack { .. } => 2usize,
542 Self::ResetStream { .. } => 3usize,
543 Self::StopSending { .. } => 4usize,
544 Self::Crypto { .. } => 5usize,
545 Self::NewToken { .. } => 6usize,
546 Self::Stream { .. } => 7usize,
547 Self::MaxData { .. } => 8usize,
548 Self::MaxStreamData { .. } => 9usize,
549 Self::MaxStreams { .. } => 10usize,
550 Self::DataBlocked { .. } => 11usize,
551 Self::StreamDataBlocked { .. } => 12usize,
552 Self::StreamsBlocked { .. } => 13usize,
553 Self::NewConnectionId { .. } => 14usize,
554 Self::RetireConnectionId { .. } => 15usize,
555 Self::PathChallenge { .. } => 16usize,
556 Self::PathResponse { .. } => 17usize,
557 Self::ConnectionClose { .. } => 18usize,
558 Self::HandshakeDone { .. } => 19usize,
559 Self::Datagram { .. } => 20usize,
560 Self::DcStatelessResetTokens { .. } => 21usize,
561 }
562 }
563 }
564 #[derive(Clone, Debug)]
565 #[non_exhaustive]
566 pub enum StreamType {
567 #[non_exhaustive]
568 Bidirectional {},
569 #[non_exhaustive]
570 Unidirectional {},
571 }
572 impl aggregate::AsVariant for StreamType {
573 const VARIANTS: &'static [aggregate::info::Variant] = &[
574 aggregate::info::variant::Builder {
575 name: aggregate::info::Str::new("BIDIRECTIONAL\0"),
576 id: 0usize,
577 }
578 .build(),
579 aggregate::info::variant::Builder {
580 name: aggregate::info::Str::new("UNIDIRECTIONAL\0"),
581 id: 1usize,
582 }
583 .build(),
584 ];
585 #[inline]
586 fn variant_idx(&self) -> usize {
587 match self {
588 Self::Bidirectional { .. } => 0usize,
589 Self::Unidirectional { .. } => 1usize,
590 }
591 }
592 }
593 #[derive(Clone, Debug)]
594 #[non_exhaustive]
595 pub enum PacketHeader {
596 #[non_exhaustive]
597 Initial { number: u64, version: u32 },
598 #[non_exhaustive]
599 Handshake { number: u64, version: u32 },
600 #[non_exhaustive]
601 ZeroRtt { number: u64, version: u32 },
602 #[non_exhaustive]
603 OneRtt { number: u64 },
604 #[non_exhaustive]
605 Retry { version: u32 },
606 #[non_exhaustive]
607 VersionNegotiation {},
608 #[non_exhaustive]
609 StatelessReset {},
610 }
611 impl aggregate::AsVariant for PacketHeader {
612 const VARIANTS: &'static [aggregate::info::Variant] = &[
613 aggregate::info::variant::Builder {
614 name: aggregate::info::Str::new("INITIAL\0"),
615 id: 0usize,
616 }
617 .build(),
618 aggregate::info::variant::Builder {
619 name: aggregate::info::Str::new("HANDSHAKE\0"),
620 id: 1usize,
621 }
622 .build(),
623 aggregate::info::variant::Builder {
624 name: aggregate::info::Str::new("ZERO_RTT\0"),
625 id: 2usize,
626 }
627 .build(),
628 aggregate::info::variant::Builder {
629 name: aggregate::info::Str::new("ONE_RTT\0"),
630 id: 3usize,
631 }
632 .build(),
633 aggregate::info::variant::Builder {
634 name: aggregate::info::Str::new("RETRY\0"),
635 id: 4usize,
636 }
637 .build(),
638 aggregate::info::variant::Builder {
639 name: aggregate::info::Str::new("VERSION_NEGOTIATION\0"),
640 id: 5usize,
641 }
642 .build(),
643 aggregate::info::variant::Builder {
644 name: aggregate::info::Str::new("STATELESS_RESET\0"),
645 id: 6usize,
646 }
647 .build(),
648 ];
649 #[inline]
650 fn variant_idx(&self) -> usize {
651 match self {
652 Self::Initial { .. } => 0usize,
653 Self::Handshake { .. } => 1usize,
654 Self::ZeroRtt { .. } => 2usize,
655 Self::OneRtt { .. } => 3usize,
656 Self::Retry { .. } => 4usize,
657 Self::VersionNegotiation { .. } => 5usize,
658 Self::StatelessReset { .. } => 6usize,
659 }
660 }
661 }
662 #[derive(Clone, Debug)]
663 #[non_exhaustive]
664 pub enum PacketType {
665 #[non_exhaustive]
666 Initial {},
667 #[non_exhaustive]
668 Handshake {},
669 #[non_exhaustive]
670 ZeroRtt {},
671 #[non_exhaustive]
672 OneRtt {},
673 #[non_exhaustive]
674 Retry {},
675 #[non_exhaustive]
676 VersionNegotiation {},
677 #[non_exhaustive]
678 StatelessReset {},
679 }
680 impl aggregate::AsVariant for PacketType {
681 const VARIANTS: &'static [aggregate::info::Variant] = &[
682 aggregate::info::variant::Builder {
683 name: aggregate::info::Str::new("INITIAL\0"),
684 id: 0usize,
685 }
686 .build(),
687 aggregate::info::variant::Builder {
688 name: aggregate::info::Str::new("HANDSHAKE\0"),
689 id: 1usize,
690 }
691 .build(),
692 aggregate::info::variant::Builder {
693 name: aggregate::info::Str::new("ZERO_RTT\0"),
694 id: 2usize,
695 }
696 .build(),
697 aggregate::info::variant::Builder {
698 name: aggregate::info::Str::new("ONE_RTT\0"),
699 id: 3usize,
700 }
701 .build(),
702 aggregate::info::variant::Builder {
703 name: aggregate::info::Str::new("RETRY\0"),
704 id: 4usize,
705 }
706 .build(),
707 aggregate::info::variant::Builder {
708 name: aggregate::info::Str::new("VERSION_NEGOTIATION\0"),
709 id: 5usize,
710 }
711 .build(),
712 aggregate::info::variant::Builder {
713 name: aggregate::info::Str::new("STATELESS_RESET\0"),
714 id: 6usize,
715 }
716 .build(),
717 ];
718 #[inline]
719 fn variant_idx(&self) -> usize {
720 match self {
721 Self::Initial { .. } => 0usize,
722 Self::Handshake { .. } => 1usize,
723 Self::ZeroRtt { .. } => 2usize,
724 Self::OneRtt { .. } => 3usize,
725 Self::Retry { .. } => 4usize,
726 Self::VersionNegotiation { .. } => 5usize,
727 Self::StatelessReset { .. } => 6usize,
728 }
729 }
730 }
731 #[derive(Clone, Debug)]
732 #[non_exhaustive]
733 pub enum KeyType {
734 #[non_exhaustive]
735 Initial {},
736 #[non_exhaustive]
737 Handshake {},
738 #[non_exhaustive]
739 ZeroRtt {},
740 #[non_exhaustive]
741 OneRtt { generation: u16 },
742 }
743 impl aggregate::AsVariant for KeyType {
744 const VARIANTS: &'static [aggregate::info::Variant] = &[
745 aggregate::info::variant::Builder {
746 name: aggregate::info::Str::new("INITIAL\0"),
747 id: 0usize,
748 }
749 .build(),
750 aggregate::info::variant::Builder {
751 name: aggregate::info::Str::new("HANDSHAKE\0"),
752 id: 1usize,
753 }
754 .build(),
755 aggregate::info::variant::Builder {
756 name: aggregate::info::Str::new("ZERO_RTT\0"),
757 id: 2usize,
758 }
759 .build(),
760 aggregate::info::variant::Builder {
761 name: aggregate::info::Str::new("ONE_RTT\0"),
762 id: 3usize,
763 }
764 .build(),
765 ];
766 #[inline]
767 fn variant_idx(&self) -> usize {
768 match self {
769 Self::Initial { .. } => 0usize,
770 Self::Handshake { .. } => 1usize,
771 Self::ZeroRtt { .. } => 2usize,
772 Self::OneRtt { .. } => 3usize,
773 }
774 }
775 }
776 #[derive(Clone, Debug)]
777 #[non_exhaustive]
778 #[doc = " A context from which the event is being emitted"]
779 #[doc = ""]
780 #[doc = " An event can occur in the context of an Endpoint or Connection"]
781 pub enum Subject {
782 #[non_exhaustive]
783 Endpoint {},
784 #[non_exhaustive]
785 #[doc = " This maps to an internal connection id, which is a stable identifier across CID changes."]
786 Connection { id: u64 },
787 }
788 impl aggregate::AsVariant for Subject {
789 const VARIANTS: &'static [aggregate::info::Variant] = &[
790 aggregate::info::variant::Builder {
791 name: aggregate::info::Str::new("ENDPOINT\0"),
792 id: 0usize,
793 }
794 .build(),
795 aggregate::info::variant::Builder {
796 name: aggregate::info::Str::new("CONNECTION\0"),
797 id: 1usize,
798 }
799 .build(),
800 ];
801 #[inline]
802 fn variant_idx(&self) -> usize {
803 match self {
804 Self::Endpoint { .. } => 0usize,
805 Self::Connection { .. } => 1usize,
806 }
807 }
808 }
809 #[derive(Clone, Debug)]
810 #[doc = " An endpoint may be either a Server or a Client"]
811 pub enum EndpointType {
812 #[non_exhaustive]
813 Server {},
814 #[non_exhaustive]
815 Client {},
816 }
817 impl aggregate::AsVariant for EndpointType {
818 const VARIANTS: &'static [aggregate::info::Variant] = &[
819 aggregate::info::variant::Builder {
820 name: aggregate::info::Str::new("SERVER\0"),
821 id: 0usize,
822 }
823 .build(),
824 aggregate::info::variant::Builder {
825 name: aggregate::info::Str::new("CLIENT\0"),
826 id: 1usize,
827 }
828 .build(),
829 ];
830 #[inline]
831 fn variant_idx(&self) -> usize {
832 match self {
833 Self::Server { .. } => 0usize,
834 Self::Client { .. } => 1usize,
835 }
836 }
837 }
838 #[derive(Clone, Debug)]
839 #[non_exhaustive]
840 pub enum DatagramDropReason {
841 #[non_exhaustive]
842 #[doc = " There was an error while attempting to decode the datagram."]
843 DecodingFailed {},
844 #[non_exhaustive]
845 #[doc = " There was an error while parsing the Retry token."]
846 InvalidRetryToken {},
847 #[non_exhaustive]
848 #[doc = " The peer specified an unsupported QUIC version."]
849 UnsupportedVersion {},
850 #[non_exhaustive]
851 #[doc = " The peer sent an invalid Destination Connection Id."]
852 InvalidDestinationConnectionId {},
853 #[non_exhaustive]
854 #[doc = " The peer sent an invalid Source Connection Id."]
855 InvalidSourceConnectionId {},
856 #[non_exhaustive]
857 #[doc = " Application provided invalid MTU configuration."]
858 InvalidMtuConfiguration {
859 #[doc = " MTU configuration for the endpoint"]
860 endpoint_mtu_config: MtuConfig,
861 },
862 #[non_exhaustive]
863 #[doc = " The Destination Connection Id is unknown and does not map to a Connection."]
864 #[doc = ""]
865 #[doc = " Connections are mapped to Destination Connections Ids (DCID) and packets"]
866 #[doc = " in a Datagram are routed to a connection based on the DCID in the first"]
867 #[doc = " packet. If a Connection is not found for the specified DCID then the"]
868 #[doc = " datagram can not be processed and is dropped."]
869 UnknownDestinationConnectionId {},
870 #[non_exhaustive]
871 #[doc = " The connection attempt was rejected."]
872 RejectedConnectionAttempt {},
873 #[non_exhaustive]
874 #[doc = " A datagram was received from an unknown server address."]
875 UnknownServerAddress {},
876 #[non_exhaustive]
877 #[doc = " The peer initiated a connection migration before the handshake was confirmed."]
878 #[doc = ""]
879 #[doc = " Note: This drop reason is no longer emitted"]
880 ConnectionMigrationDuringHandshake {},
881 #[non_exhaustive]
882 #[doc = " The attempted connection migration was rejected."]
883 RejectedConnectionMigration { reason: MigrationDenyReason },
884 #[non_exhaustive]
885 #[doc = " The maximum number of paths per connection was exceeded."]
886 PathLimitExceeded {},
887 #[non_exhaustive]
888 #[doc = " The peer initiated a connection migration without supplying enough connection IDs to use."]
889 #[doc = ""]
890 #[doc = " Note: This drop reason is no longer emitted"]
891 InsufficientConnectionIds {},
892 }
893 impl aggregate::AsVariant for DatagramDropReason {
894 const VARIANTS: &'static [aggregate::info::Variant] = &[
895 aggregate::info::variant::Builder {
896 name: aggregate::info::Str::new("DECODING_FAILED\0"),
897 id: 0usize,
898 }
899 .build(),
900 aggregate::info::variant::Builder {
901 name: aggregate::info::Str::new("INVALID_RETRY_TOKEN\0"),
902 id: 1usize,
903 }
904 .build(),
905 aggregate::info::variant::Builder {
906 name: aggregate::info::Str::new("UNSUPPORTED_VERSION\0"),
907 id: 2usize,
908 }
909 .build(),
910 aggregate::info::variant::Builder {
911 name: aggregate::info::Str::new("INVALID_DESTINATION_CONNECTION_ID\0"),
912 id: 3usize,
913 }
914 .build(),
915 aggregate::info::variant::Builder {
916 name: aggregate::info::Str::new("INVALID_SOURCE_CONNECTION_ID\0"),
917 id: 4usize,
918 }
919 .build(),
920 aggregate::info::variant::Builder {
921 name: aggregate::info::Str::new("INVALID_MTU_CONFIGURATION\0"),
922 id: 5usize,
923 }
924 .build(),
925 aggregate::info::variant::Builder {
926 name: aggregate::info::Str::new("UNKNOWN_DESTINATION_CONNECTION_ID\0"),
927 id: 6usize,
928 }
929 .build(),
930 aggregate::info::variant::Builder {
931 name: aggregate::info::Str::new("REJECTED_CONNECTION_ATTEMPT\0"),
932 id: 7usize,
933 }
934 .build(),
935 aggregate::info::variant::Builder {
936 name: aggregate::info::Str::new("UNKNOWN_SERVER_ADDRESS\0"),
937 id: 8usize,
938 }
939 .build(),
940 aggregate::info::variant::Builder {
941 name: aggregate::info::Str::new("CONNECTION_MIGRATION_DURING_HANDSHAKE\0"),
942 id: 9usize,
943 }
944 .build(),
945 aggregate::info::variant::Builder {
946 name: aggregate::info::Str::new("REJECTED_CONNECTION_MIGRATION\0"),
947 id: 10usize,
948 }
949 .build(),
950 aggregate::info::variant::Builder {
951 name: aggregate::info::Str::new("PATH_LIMIT_EXCEEDED\0"),
952 id: 11usize,
953 }
954 .build(),
955 aggregate::info::variant::Builder {
956 name: aggregate::info::Str::new("INSUFFICIENT_CONNECTION_IDS\0"),
957 id: 12usize,
958 }
959 .build(),
960 ];
961 #[inline]
962 fn variant_idx(&self) -> usize {
963 match self {
964 Self::DecodingFailed { .. } => 0usize,
965 Self::InvalidRetryToken { .. } => 1usize,
966 Self::UnsupportedVersion { .. } => 2usize,
967 Self::InvalidDestinationConnectionId { .. } => 3usize,
968 Self::InvalidSourceConnectionId { .. } => 4usize,
969 Self::InvalidMtuConfiguration { .. } => 5usize,
970 Self::UnknownDestinationConnectionId { .. } => 6usize,
971 Self::RejectedConnectionAttempt { .. } => 7usize,
972 Self::UnknownServerAddress { .. } => 8usize,
973 Self::ConnectionMigrationDuringHandshake { .. } => 9usize,
974 Self::RejectedConnectionMigration { .. } => 10usize,
975 Self::PathLimitExceeded { .. } => 11usize,
976 Self::InsufficientConnectionIds { .. } => 12usize,
977 }
978 }
979 }
980 #[derive(Clone, Debug)]
981 #[non_exhaustive]
982 pub enum KeySpace {
983 #[non_exhaustive]
984 Initial {},
985 #[non_exhaustive]
986 Handshake {},
987 #[non_exhaustive]
988 ZeroRtt {},
989 #[non_exhaustive]
990 OneRtt {},
991 }
992 impl aggregate::AsVariant for KeySpace {
993 const VARIANTS: &'static [aggregate::info::Variant] = &[
994 aggregate::info::variant::Builder {
995 name: aggregate::info::Str::new("INITIAL\0"),
996 id: 0usize,
997 }
998 .build(),
999 aggregate::info::variant::Builder {
1000 name: aggregate::info::Str::new("HANDSHAKE\0"),
1001 id: 1usize,
1002 }
1003 .build(),
1004 aggregate::info::variant::Builder {
1005 name: aggregate::info::Str::new("ZERO_RTT\0"),
1006 id: 2usize,
1007 }
1008 .build(),
1009 aggregate::info::variant::Builder {
1010 name: aggregate::info::Str::new("ONE_RTT\0"),
1011 id: 3usize,
1012 }
1013 .build(),
1014 ];
1015 #[inline]
1016 fn variant_idx(&self) -> usize {
1017 match self {
1018 Self::Initial { .. } => 0usize,
1019 Self::Handshake { .. } => 1usize,
1020 Self::ZeroRtt { .. } => 2usize,
1021 Self::OneRtt { .. } => 3usize,
1022 }
1023 }
1024 }
1025 #[derive(Clone, Debug)]
1026 #[non_exhaustive]
1027 pub enum PacketSkipReason {
1028 #[non_exhaustive]
1029 #[doc = " Skipped a packet number to elicit a quicker PTO acknowledgment"]
1030 PtoProbe {},
1031 #[non_exhaustive]
1032 #[doc = " Skipped a packet number to detect an Optimistic Ack attack"]
1033 OptimisticAckMitigation {},
1034 }
1035 impl aggregate::AsVariant for PacketSkipReason {
1036 const VARIANTS: &'static [aggregate::info::Variant] = &[
1037 aggregate::info::variant::Builder {
1038 name: aggregate::info::Str::new("PTO_PROBE\0"),
1039 id: 0usize,
1040 }
1041 .build(),
1042 aggregate::info::variant::Builder {
1043 name: aggregate::info::Str::new("OPTIMISTIC_ACK_MITIGATION\0"),
1044 id: 1usize,
1045 }
1046 .build(),
1047 ];
1048 #[inline]
1049 fn variant_idx(&self) -> usize {
1050 match self {
1051 Self::PtoProbe { .. } => 0usize,
1052 Self::OptimisticAckMitigation { .. } => 1usize,
1053 }
1054 }
1055 }
1056 #[derive(Clone, Debug)]
1057 #[non_exhaustive]
1058 pub enum PacketDropReason<'a> {
1059 #[non_exhaustive]
1060 #[doc = " A connection error occurred and is no longer able to process packets."]
1061 ConnectionError { path: Path<'a> },
1062 #[non_exhaustive]
1063 #[doc = " The handshake needed to be complete before processing the packet."]
1064 #[doc = ""]
1065 #[doc = " To ensure the connection stays secure, short packets can only be processed"]
1066 #[doc = " once the handshake has completed."]
1067 HandshakeNotComplete { path: Path<'a> },
1068 #[non_exhaustive]
1069 #[doc = " The packet contained a version which did not match the version negotiated"]
1070 #[doc = " during the handshake."]
1071 VersionMismatch { version: u32, path: Path<'a> },
1072 #[non_exhaustive]
1073 #[doc = " A datagram contained more than one destination connection ID, which is"]
1074 #[doc = " not allowed."]
1075 ConnectionIdMismatch {
1076 packet_cid: &'a [u8],
1077 path: Path<'a>,
1078 },
1079 #[non_exhaustive]
1080 #[doc = " There was a failure when attempting to remove header protection."]
1081 UnprotectFailed { space: KeySpace, path: Path<'a> },
1082 #[non_exhaustive]
1083 #[doc = " There was a failure when attempting to decrypt the packet."]
1084 DecryptionFailed {
1085 path: Path<'a>,
1086 packet_header: PacketHeader,
1087 },
1088 #[non_exhaustive]
1089 #[doc = " Packet decoding failed."]
1090 #[doc = ""]
1091 #[doc = " The payload is decoded one packet at a time. If decoding fails"]
1092 #[doc = " then the remaining packets are also discarded."]
1093 DecodingFailed { path: Path<'a> },
1094 #[non_exhaustive]
1095 #[doc = " The client received a non-empty retry token."]
1096 NonEmptyRetryToken { path: Path<'a> },
1097 #[non_exhaustive]
1098 #[doc = " A Retry packet was discarded."]
1099 RetryDiscarded {
1100 reason: RetryDiscardReason<'a>,
1101 path: Path<'a>,
1102 },
1103 #[non_exhaustive]
1104 #[doc = " The received Initial packet was not transported in a datagram of at least 1200 bytes"]
1105 UndersizedInitialPacket { path: Path<'a> },
1106 #[non_exhaustive]
1107 #[doc = " The destination connection ID in the packet was the initial connection ID but was in"]
1108 #[doc = " a non-initial packet."]
1109 InitialConnectionIdInvalidSpace {
1110 path: Path<'a>,
1111 packet_type: PacketType,
1112 },
1113 #[non_exhaustive]
1114 #[doc = " The packet space for a received packet did not exist"]
1115 PacketSpaceDoesNotExist {
1116 path: Path<'a>,
1117 packet_type: PacketType,
1118 },
1119 }
1120 impl<'a> aggregate::AsVariant for PacketDropReason<'a> {
1121 const VARIANTS: &'static [aggregate::info::Variant] = &[
1122 aggregate::info::variant::Builder {
1123 name: aggregate::info::Str::new("CONNECTION_ERROR\0"),
1124 id: 0usize,
1125 }
1126 .build(),
1127 aggregate::info::variant::Builder {
1128 name: aggregate::info::Str::new("HANDSHAKE_NOT_COMPLETE\0"),
1129 id: 1usize,
1130 }
1131 .build(),
1132 aggregate::info::variant::Builder {
1133 name: aggregate::info::Str::new("VERSION_MISMATCH\0"),
1134 id: 2usize,
1135 }
1136 .build(),
1137 aggregate::info::variant::Builder {
1138 name: aggregate::info::Str::new("CONNECTION_ID_MISMATCH\0"),
1139 id: 3usize,
1140 }
1141 .build(),
1142 aggregate::info::variant::Builder {
1143 name: aggregate::info::Str::new("UNPROTECT_FAILED\0"),
1144 id: 4usize,
1145 }
1146 .build(),
1147 aggregate::info::variant::Builder {
1148 name: aggregate::info::Str::new("DECRYPTION_FAILED\0"),
1149 id: 5usize,
1150 }
1151 .build(),
1152 aggregate::info::variant::Builder {
1153 name: aggregate::info::Str::new("DECODING_FAILED\0"),
1154 id: 6usize,
1155 }
1156 .build(),
1157 aggregate::info::variant::Builder {
1158 name: aggregate::info::Str::new("NON_EMPTY_RETRY_TOKEN\0"),
1159 id: 7usize,
1160 }
1161 .build(),
1162 aggregate::info::variant::Builder {
1163 name: aggregate::info::Str::new("RETRY_DISCARDED\0"),
1164 id: 8usize,
1165 }
1166 .build(),
1167 aggregate::info::variant::Builder {
1168 name: aggregate::info::Str::new("UNDERSIZED_INITIAL_PACKET\0"),
1169 id: 9usize,
1170 }
1171 .build(),
1172 aggregate::info::variant::Builder {
1173 name: aggregate::info::Str::new("INITIAL_CONNECTION_ID_INVALID_SPACE\0"),
1174 id: 10usize,
1175 }
1176 .build(),
1177 aggregate::info::variant::Builder {
1178 name: aggregate::info::Str::new("PACKET_SPACE_DOES_NOT_EXIST\0"),
1179 id: 11usize,
1180 }
1181 .build(),
1182 ];
1183 #[inline]
1184 fn variant_idx(&self) -> usize {
1185 match self {
1186 Self::ConnectionError { .. } => 0usize,
1187 Self::HandshakeNotComplete { .. } => 1usize,
1188 Self::VersionMismatch { .. } => 2usize,
1189 Self::ConnectionIdMismatch { .. } => 3usize,
1190 Self::UnprotectFailed { .. } => 4usize,
1191 Self::DecryptionFailed { .. } => 5usize,
1192 Self::DecodingFailed { .. } => 6usize,
1193 Self::NonEmptyRetryToken { .. } => 7usize,
1194 Self::RetryDiscarded { .. } => 8usize,
1195 Self::UndersizedInitialPacket { .. } => 9usize,
1196 Self::InitialConnectionIdInvalidSpace { .. } => 10usize,
1197 Self::PacketSpaceDoesNotExist { .. } => 11usize,
1198 }
1199 }
1200 }
1201 #[derive(Clone, Debug)]
1202 #[non_exhaustive]
1203 #[deprecated(note = "use on_rx_ack_range_dropped event instead")]
1204 pub enum AckAction {
1205 #[non_exhaustive]
1206 #[doc = " Ack range for received packets was dropped due to space constraints"]
1207 #[doc = ""]
1208 #[doc = " For the purpose of processing Acks, RX packet numbers are stored as"]
1209 #[doc = " packet_number ranges in an IntervalSet; only lower and upper bounds"]
1210 #[doc = " are stored instead of individual packet_numbers. Ranges are merged"]
1211 #[doc = " when possible so only disjointed ranges are stored."]
1212 #[doc = ""]
1213 #[doc = " When at `capacity`, the lowest packet_number range is dropped."]
1214 RxAckRangeDropped {
1215 #[doc = " The packet number range which was dropped"]
1216 packet_number_range: core::ops::RangeInclusive<u64>,
1217 #[doc = " The number of disjoint ranges the IntervalSet can store"]
1218 capacity: usize,
1219 #[doc = " The store packet_number range in the IntervalSet"]
1220 stored_range: core::ops::RangeInclusive<u64>,
1221 },
1222 }
1223 #[allow(deprecated)]
1224 impl aggregate::AsVariant for AckAction {
1225 const VARIANTS: &'static [aggregate::info::Variant] =
1226 &[aggregate::info::variant::Builder {
1227 name: aggregate::info::Str::new("RX_ACK_RANGE_DROPPED\0"),
1228 id: 0usize,
1229 }
1230 .build()];
1231 #[inline]
1232 fn variant_idx(&self) -> usize {
1233 match self {
1234 Self::RxAckRangeDropped { .. } => 0usize,
1235 }
1236 }
1237 }
1238 #[derive(Clone, Debug)]
1239 #[non_exhaustive]
1240 pub enum RetryDiscardReason<'a> {
1241 #[non_exhaustive]
1242 #[doc = " Received a Retry packet with SCID field equal to DCID field."]
1243 ScidEqualsDcid { cid: &'a [u8] },
1244 #[non_exhaustive]
1245 #[doc = " A client only processes at most one Retry packet."]
1246 RetryAlreadyProcessed {},
1247 #[non_exhaustive]
1248 #[doc = " The client discards Retry packets if a valid Initial packet"]
1249 #[doc = " has been received and processed."]
1250 InitialAlreadyProcessed {},
1251 #[non_exhaustive]
1252 #[doc = " The Retry packet received contained an invalid retry integrity tag"]
1253 InvalidIntegrityTag {},
1254 }
1255 impl<'a> aggregate::AsVariant for RetryDiscardReason<'a> {
1256 const VARIANTS: &'static [aggregate::info::Variant] = &[
1257 aggregate::info::variant::Builder {
1258 name: aggregate::info::Str::new("SCID_EQUALS_DCID\0"),
1259 id: 0usize,
1260 }
1261 .build(),
1262 aggregate::info::variant::Builder {
1263 name: aggregate::info::Str::new("RETRY_ALREADY_PROCESSED\0"),
1264 id: 1usize,
1265 }
1266 .build(),
1267 aggregate::info::variant::Builder {
1268 name: aggregate::info::Str::new("INITIAL_ALREADY_PROCESSED\0"),
1269 id: 2usize,
1270 }
1271 .build(),
1272 aggregate::info::variant::Builder {
1273 name: aggregate::info::Str::new("INVALID_INTEGRITY_TAG\0"),
1274 id: 3usize,
1275 }
1276 .build(),
1277 ];
1278 #[inline]
1279 fn variant_idx(&self) -> usize {
1280 match self {
1281 Self::ScidEqualsDcid { .. } => 0usize,
1282 Self::RetryAlreadyProcessed { .. } => 1usize,
1283 Self::InitialAlreadyProcessed { .. } => 2usize,
1284 Self::InvalidIntegrityTag { .. } => 3usize,
1285 }
1286 }
1287 }
1288 #[derive(Clone, Debug)]
1289 #[non_exhaustive]
1290 pub enum MigrationDenyReason {
1291 #[non_exhaustive]
1292 BlockedPort {},
1293 #[non_exhaustive]
1294 PortScopeChanged {},
1295 #[non_exhaustive]
1296 IpScopeChange {},
1297 #[non_exhaustive]
1298 ConnectionMigrationDisabled {},
1299 }
1300 impl aggregate::AsVariant for MigrationDenyReason {
1301 const VARIANTS: &'static [aggregate::info::Variant] = &[
1302 aggregate::info::variant::Builder {
1303 name: aggregate::info::Str::new("BLOCKED_PORT\0"),
1304 id: 0usize,
1305 }
1306 .build(),
1307 aggregate::info::variant::Builder {
1308 name: aggregate::info::Str::new("PORT_SCOPE_CHANGED\0"),
1309 id: 1usize,
1310 }
1311 .build(),
1312 aggregate::info::variant::Builder {
1313 name: aggregate::info::Str::new("IP_SCOPE_CHANGE\0"),
1314 id: 2usize,
1315 }
1316 .build(),
1317 aggregate::info::variant::Builder {
1318 name: aggregate::info::Str::new("CONNECTION_MIGRATION_DISABLED\0"),
1319 id: 3usize,
1320 }
1321 .build(),
1322 ];
1323 #[inline]
1324 fn variant_idx(&self) -> usize {
1325 match self {
1326 Self::BlockedPort { .. } => 0usize,
1327 Self::PortScopeChanged { .. } => 1usize,
1328 Self::IpScopeChange { .. } => 2usize,
1329 Self::ConnectionMigrationDisabled { .. } => 3usize,
1330 }
1331 }
1332 }
1333 #[derive(Clone, Debug)]
1334 #[non_exhaustive]
1335 #[doc = " The current state of the ECN controller for the path"]
1336 pub enum EcnState {
1337 #[non_exhaustive]
1338 #[doc = " ECN capability is being actively tested"]
1339 Testing {},
1340 #[non_exhaustive]
1341 #[doc = " ECN capability has been tested, but not validated yet"]
1342 Unknown {},
1343 #[non_exhaustive]
1344 #[doc = " ECN capability testing has failed validation"]
1345 Failed {},
1346 #[non_exhaustive]
1347 #[doc = " ECN capability has been confirmed"]
1348 Capable {},
1349 }
1350 impl aggregate::AsVariant for EcnState {
1351 const VARIANTS: &'static [aggregate::info::Variant] = &[
1352 aggregate::info::variant::Builder {
1353 name: aggregate::info::Str::new("TESTING\0"),
1354 id: 0usize,
1355 }
1356 .build(),
1357 aggregate::info::variant::Builder {
1358 name: aggregate::info::Str::new("UNKNOWN\0"),
1359 id: 1usize,
1360 }
1361 .build(),
1362 aggregate::info::variant::Builder {
1363 name: aggregate::info::Str::new("FAILED\0"),
1364 id: 2usize,
1365 }
1366 .build(),
1367 aggregate::info::variant::Builder {
1368 name: aggregate::info::Str::new("CAPABLE\0"),
1369 id: 3usize,
1370 }
1371 .build(),
1372 ];
1373 #[inline]
1374 fn variant_idx(&self) -> usize {
1375 match self {
1376 Self::Testing { .. } => 0usize,
1377 Self::Unknown { .. } => 1usize,
1378 Self::Failed { .. } => 2usize,
1379 Self::Capable { .. } => 3usize,
1380 }
1381 }
1382 }
1383 #[derive(Clone, Debug)]
1384 #[non_exhaustive]
1385 #[doc = " Events tracking the progress of handshake status"]
1386 pub enum HandshakeStatus {
1387 #[non_exhaustive]
1388 #[doc = " The handshake has completed."]
1389 Complete {},
1390 #[non_exhaustive]
1391 #[doc = " The handshake has been confirmed."]
1392 Confirmed {},
1393 #[non_exhaustive]
1394 #[doc = " A HANDSHAKE_DONE frame was delivered or received."]
1395 #[doc = ""]
1396 #[doc = " A Client endpoint receives a HANDSHAKE_DONE frame and"]
1397 #[doc = " only a Server is allowed to send the HANDSHAKE_DONE"]
1398 #[doc = " frame."]
1399 HandshakeDoneAcked {},
1400 #[non_exhaustive]
1401 #[doc = " A HANDSHAKE_DONE frame was declared lost."]
1402 #[doc = ""]
1403 #[doc = " The Server is responsible for re-transmitting the"]
1404 #[doc = " HANDSHAKE_DONE frame until it is acked by the peer."]
1405 HandshakeDoneLost {},
1406 }
1407 impl aggregate::AsVariant for HandshakeStatus {
1408 const VARIANTS: &'static [aggregate::info::Variant] = &[
1409 aggregate::info::variant::Builder {
1410 name: aggregate::info::Str::new("COMPLETE\0"),
1411 id: 0usize,
1412 }
1413 .build(),
1414 aggregate::info::variant::Builder {
1415 name: aggregate::info::Str::new("CONFIRMED\0"),
1416 id: 1usize,
1417 }
1418 .build(),
1419 aggregate::info::variant::Builder {
1420 name: aggregate::info::Str::new("HANDSHAKE_DONE_ACKED\0"),
1421 id: 2usize,
1422 }
1423 .build(),
1424 aggregate::info::variant::Builder {
1425 name: aggregate::info::Str::new("HANDSHAKE_DONE_LOST\0"),
1426 id: 3usize,
1427 }
1428 .build(),
1429 ];
1430 #[inline]
1431 fn variant_idx(&self) -> usize {
1432 match self {
1433 Self::Complete { .. } => 0usize,
1434 Self::Confirmed { .. } => 1usize,
1435 Self::HandshakeDoneAcked { .. } => 2usize,
1436 Self::HandshakeDoneLost { .. } => 3usize,
1437 }
1438 }
1439 }
1440 #[derive(Clone, Debug)]
1441 #[non_exhaustive]
1442 #[doc = " The source that caused a congestion event"]
1443 pub enum CongestionSource {
1444 #[non_exhaustive]
1445 #[doc = " Explicit Congestion Notification"]
1446 Ecn {},
1447 #[non_exhaustive]
1448 #[doc = " One or more packets were detected lost"]
1449 PacketLoss {},
1450 }
1451 impl aggregate::AsVariant for CongestionSource {
1452 const VARIANTS: &'static [aggregate::info::Variant] = &[
1453 aggregate::info::variant::Builder {
1454 name: aggregate::info::Str::new("ECN\0"),
1455 id: 0usize,
1456 }
1457 .build(),
1458 aggregate::info::variant::Builder {
1459 name: aggregate::info::Str::new("PACKET_LOSS\0"),
1460 id: 1usize,
1461 }
1462 .build(),
1463 ];
1464 #[inline]
1465 fn variant_idx(&self) -> usize {
1466 match self {
1467 Self::Ecn { .. } => 0usize,
1468 Self::PacketLoss { .. } => 1usize,
1469 }
1470 }
1471 }
1472 #[non_exhaustive]
1473 #[derive(Copy, Clone, Debug, Eq, PartialEq)]
1474 #[allow(non_camel_case_types)]
1475 pub enum CipherSuite {
1476 #[non_exhaustive]
1477 TLS_AES_128_GCM_SHA256 {},
1478 #[non_exhaustive]
1479 TLS_AES_256_GCM_SHA384 {},
1480 #[non_exhaustive]
1481 TLS_CHACHA20_POLY1305_SHA256 {},
1482 #[non_exhaustive]
1483 Unknown {},
1484 }
1485 impl aggregate::AsVariant for CipherSuite {
1486 const VARIANTS: &'static [aggregate::info::Variant] = &[
1487 aggregate::info::variant::Builder {
1488 name: aggregate::info::Str::new("TLS_AES_128_GCM_SHA256\0"),
1489 id: 0usize,
1490 }
1491 .build(),
1492 aggregate::info::variant::Builder {
1493 name: aggregate::info::Str::new("TLS_AES_256_GCM_SHA384\0"),
1494 id: 1usize,
1495 }
1496 .build(),
1497 aggregate::info::variant::Builder {
1498 name: aggregate::info::Str::new("TLS_CHACHA20_POLY1305_SHA256\0"),
1499 id: 2usize,
1500 }
1501 .build(),
1502 aggregate::info::variant::Builder {
1503 name: aggregate::info::Str::new("UNKNOWN\0"),
1504 id: 3usize,
1505 }
1506 .build(),
1507 ];
1508 #[inline]
1509 fn variant_idx(&self) -> usize {
1510 match self {
1511 Self::TLS_AES_128_GCM_SHA256 { .. } => 0usize,
1512 Self::TLS_AES_256_GCM_SHA384 { .. } => 1usize,
1513 Self::TLS_CHACHA20_POLY1305_SHA256 { .. } => 2usize,
1514 Self::Unknown { .. } => 3usize,
1515 }
1516 }
1517 }
1518 #[derive(Clone, Debug)]
1519 #[non_exhaustive]
1520 pub enum PathChallengeStatus {
1521 #[non_exhaustive]
1522 Validated {},
1523 #[non_exhaustive]
1524 Abandoned {},
1525 }
1526 impl aggregate::AsVariant for PathChallengeStatus {
1527 const VARIANTS: &'static [aggregate::info::Variant] = &[
1528 aggregate::info::variant::Builder {
1529 name: aggregate::info::Str::new("VALIDATED\0"),
1530 id: 0usize,
1531 }
1532 .build(),
1533 aggregate::info::variant::Builder {
1534 name: aggregate::info::Str::new("ABANDONED\0"),
1535 id: 1usize,
1536 }
1537 .build(),
1538 ];
1539 #[inline]
1540 fn variant_idx(&self) -> usize {
1541 match self {
1542 Self::Validated { .. } => 0usize,
1543 Self::Abandoned { .. } => 1usize,
1544 }
1545 }
1546 }
1547 #[derive(Clone, Debug)]
1548 #[non_exhaustive]
1549 #[doc = " The reason the slow start congestion controller state has been exited"]
1550 pub enum SlowStartExitCause {
1551 #[non_exhaustive]
1552 #[doc = " A packet was determined lost"]
1553 PacketLoss {},
1554 #[non_exhaustive]
1555 #[doc = " An Explicit Congestion Notification: Congestion Experienced marking was received"]
1556 Ecn {},
1557 #[non_exhaustive]
1558 #[doc = " The round trip time estimate was updated"]
1559 Rtt {},
1560 #[non_exhaustive]
1561 #[doc = " Slow Start exited due to a reason other than those above"]
1562 #[doc = ""]
1563 #[doc = " With the Cubic congestion controller, this reason is used after the initial exiting of"]
1564 #[doc = " Slow Start, when the previously determined Slow Start threshold is exceed by the"]
1565 #[doc = " congestion window."]
1566 Other {},
1567 }
1568 impl aggregate::AsVariant for SlowStartExitCause {
1569 const VARIANTS: &'static [aggregate::info::Variant] = &[
1570 aggregate::info::variant::Builder {
1571 name: aggregate::info::Str::new("PACKET_LOSS\0"),
1572 id: 0usize,
1573 }
1574 .build(),
1575 aggregate::info::variant::Builder {
1576 name: aggregate::info::Str::new("ECN\0"),
1577 id: 1usize,
1578 }
1579 .build(),
1580 aggregate::info::variant::Builder {
1581 name: aggregate::info::Str::new("RTT\0"),
1582 id: 2usize,
1583 }
1584 .build(),
1585 aggregate::info::variant::Builder {
1586 name: aggregate::info::Str::new("OTHER\0"),
1587 id: 3usize,
1588 }
1589 .build(),
1590 ];
1591 #[inline]
1592 fn variant_idx(&self) -> usize {
1593 match self {
1594 Self::PacketLoss { .. } => 0usize,
1595 Self::Ecn { .. } => 1usize,
1596 Self::Rtt { .. } => 2usize,
1597 Self::Other { .. } => 3usize,
1598 }
1599 }
1600 }
1601 #[derive(Clone, Debug)]
1602 #[non_exhaustive]
1603 #[doc = " The reason the MTU was updated"]
1604 pub enum MtuUpdatedCause {
1605 #[non_exhaustive]
1606 #[doc = " The MTU was initialized with the default value"]
1607 NewPath {},
1608 #[non_exhaustive]
1609 #[doc = " An MTU probe was acknowledged by the peer"]
1610 ProbeAcknowledged {},
1611 #[non_exhaustive]
1612 #[doc = " A blackhole was detected"]
1613 Blackhole {},
1614 #[non_exhaustive]
1615 #[doc = " An early packet using the configured InitialMtu was lost"]
1616 InitialMtuPacketLost {},
1617 #[non_exhaustive]
1618 #[doc = " An early packet using the configured InitialMtu was acknowledged by the peer"]
1619 InitialMtuPacketAcknowledged {},
1620 #[non_exhaustive]
1621 #[doc = " MTU probes larger than the current MTU were not acknowledged"]
1622 LargerProbesLost {},
1623 }
1624 impl aggregate::AsVariant for MtuUpdatedCause {
1625 const VARIANTS: &'static [aggregate::info::Variant] = &[
1626 aggregate::info::variant::Builder {
1627 name: aggregate::info::Str::new("NEW_PATH\0"),
1628 id: 0usize,
1629 }
1630 .build(),
1631 aggregate::info::variant::Builder {
1632 name: aggregate::info::Str::new("PROBE_ACKNOWLEDGED\0"),
1633 id: 1usize,
1634 }
1635 .build(),
1636 aggregate::info::variant::Builder {
1637 name: aggregate::info::Str::new("BLACKHOLE\0"),
1638 id: 2usize,
1639 }
1640 .build(),
1641 aggregate::info::variant::Builder {
1642 name: aggregate::info::Str::new("INITIAL_MTU_PACKET_LOST\0"),
1643 id: 3usize,
1644 }
1645 .build(),
1646 aggregate::info::variant::Builder {
1647 name: aggregate::info::Str::new("INITIAL_MTU_PACKET_ACKNOWLEDGED\0"),
1648 id: 4usize,
1649 }
1650 .build(),
1651 aggregate::info::variant::Builder {
1652 name: aggregate::info::Str::new("LARGER_PROBES_LOST\0"),
1653 id: 5usize,
1654 }
1655 .build(),
1656 ];
1657 #[inline]
1658 fn variant_idx(&self) -> usize {
1659 match self {
1660 Self::NewPath { .. } => 0usize,
1661 Self::ProbeAcknowledged { .. } => 1usize,
1662 Self::Blackhole { .. } => 2usize,
1663 Self::InitialMtuPacketLost { .. } => 3usize,
1664 Self::InitialMtuPacketAcknowledged { .. } => 4usize,
1665 Self::LargerProbesLost { .. } => 5usize,
1666 }
1667 }
1668 }
1669 #[derive(Clone, Debug)]
1670 #[non_exhaustive]
1671 pub enum BbrState {
1672 #[non_exhaustive]
1673 Startup {},
1674 #[non_exhaustive]
1675 Drain {},
1676 #[non_exhaustive]
1677 ProbeBwDown {},
1678 #[non_exhaustive]
1679 ProbeBwCruise {},
1680 #[non_exhaustive]
1681 ProbeBwRefill {},
1682 #[non_exhaustive]
1683 ProbeBwUp {},
1684 #[non_exhaustive]
1685 ProbeRtt {},
1686 }
1687 impl aggregate::AsVariant for BbrState {
1688 const VARIANTS: &'static [aggregate::info::Variant] = &[
1689 aggregate::info::variant::Builder {
1690 name: aggregate::info::Str::new("STARTUP\0"),
1691 id: 0usize,
1692 }
1693 .build(),
1694 aggregate::info::variant::Builder {
1695 name: aggregate::info::Str::new("DRAIN\0"),
1696 id: 1usize,
1697 }
1698 .build(),
1699 aggregate::info::variant::Builder {
1700 name: aggregate::info::Str::new("PROBE_BW_DOWN\0"),
1701 id: 2usize,
1702 }
1703 .build(),
1704 aggregate::info::variant::Builder {
1705 name: aggregate::info::Str::new("PROBE_BW_CRUISE\0"),
1706 id: 3usize,
1707 }
1708 .build(),
1709 aggregate::info::variant::Builder {
1710 name: aggregate::info::Str::new("PROBE_BW_REFILL\0"),
1711 id: 4usize,
1712 }
1713 .build(),
1714 aggregate::info::variant::Builder {
1715 name: aggregate::info::Str::new("PROBE_BW_UP\0"),
1716 id: 5usize,
1717 }
1718 .build(),
1719 aggregate::info::variant::Builder {
1720 name: aggregate::info::Str::new("PROBE_RTT\0"),
1721 id: 6usize,
1722 }
1723 .build(),
1724 ];
1725 #[inline]
1726 fn variant_idx(&self) -> usize {
1727 match self {
1728 Self::Startup { .. } => 0usize,
1729 Self::Drain { .. } => 1usize,
1730 Self::ProbeBwDown { .. } => 2usize,
1731 Self::ProbeBwCruise { .. } => 3usize,
1732 Self::ProbeBwRefill { .. } => 4usize,
1733 Self::ProbeBwUp { .. } => 5usize,
1734 Self::ProbeRtt { .. } => 6usize,
1735 }
1736 }
1737 }
1738 #[derive(Clone, Debug)]
1739 #[non_exhaustive]
1740 pub enum DcState {
1741 #[non_exhaustive]
1742 VersionNegotiated { version: u32 },
1743 #[non_exhaustive]
1744 NoVersionNegotiated {},
1745 #[non_exhaustive]
1746 PathSecretsReady {},
1747 #[non_exhaustive]
1748 Complete {},
1749 }
1750 impl aggregate::AsVariant for DcState {
1751 const VARIANTS: &'static [aggregate::info::Variant] = &[
1752 aggregate::info::variant::Builder {
1753 name: aggregate::info::Str::new("VERSION_NEGOTIATED\0"),
1754 id: 0usize,
1755 }
1756 .build(),
1757 aggregate::info::variant::Builder {
1758 name: aggregate::info::Str::new("NO_VERSION_NEGOTIATED\0"),
1759 id: 1usize,
1760 }
1761 .build(),
1762 aggregate::info::variant::Builder {
1763 name: aggregate::info::Str::new("PATH_SECRETS_READY\0"),
1764 id: 2usize,
1765 }
1766 .build(),
1767 aggregate::info::variant::Builder {
1768 name: aggregate::info::Str::new("COMPLETE\0"),
1769 id: 3usize,
1770 }
1771 .build(),
1772 ];
1773 #[inline]
1774 fn variant_idx(&self) -> usize {
1775 match self {
1776 Self::VersionNegotiated { .. } => 0usize,
1777 Self::NoVersionNegotiated { .. } => 1usize,
1778 Self::PathSecretsReady { .. } => 2usize,
1779 Self::Complete { .. } => 3usize,
1780 }
1781 }
1782 }
1783 #[derive(Clone, Debug)]
1784 #[non_exhaustive]
1785 #[doc = " Application level protocol"]
1786 pub struct ApplicationProtocolInformation<'a> {
1787 pub chosen_application_protocol: &'a [u8],
1788 }
1789 #[cfg(any(test, feature = "testing"))]
1790 impl<'a> crate::event::snapshot::Fmt for ApplicationProtocolInformation<'a> {
1791 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
1792 let mut fmt = fmt.debug_struct("ApplicationProtocolInformation");
1793 fmt.field(
1794 "chosen_application_protocol",
1795 &self.chosen_application_protocol,
1796 );
1797 fmt.finish()
1798 }
1799 }
1800 impl<'a> Event for ApplicationProtocolInformation<'a> {
1801 const NAME: &'static str = "transport:application_protocol_information";
1802 }
1803 #[derive(Clone, Debug)]
1804 #[non_exhaustive]
1805 #[doc = " Server Name was negotiated for the connection"]
1806 pub struct ServerNameInformation<'a> {
1807 pub chosen_server_name: &'a str,
1808 }
1809 #[cfg(any(test, feature = "testing"))]
1810 impl<'a> crate::event::snapshot::Fmt for ServerNameInformation<'a> {
1811 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
1812 let mut fmt = fmt.debug_struct("ServerNameInformation");
1813 fmt.field("chosen_server_name", &self.chosen_server_name);
1814 fmt.finish()
1815 }
1816 }
1817 impl<'a> Event for ServerNameInformation<'a> {
1818 const NAME: &'static str = "transport:server_name_information";
1819 }
1820 #[derive(Clone, Debug)]
1821 #[non_exhaustive]
1822 #[doc = " Key Exchange Group was negotiated for the connection"]
1823 #[doc = ""]
1824 #[doc = " `contains_kem` is `true` if the `chosen_group_name`"]
1825 #[doc = " contains a key encapsulation mechanism"]
1826 pub struct KeyExchangeGroup<'a> {
1827 pub chosen_group_name: &'a str,
1828 pub contains_kem: bool,
1829 }
1830 #[cfg(any(test, feature = "testing"))]
1831 impl<'a> crate::event::snapshot::Fmt for KeyExchangeGroup<'a> {
1832 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
1833 let mut fmt = fmt.debug_struct("KeyExchangeGroup");
1834 fmt.field("chosen_group_name", &self.chosen_group_name);
1835 fmt.field("contains_kem", &self.contains_kem);
1836 fmt.finish()
1837 }
1838 }
1839 impl<'a> Event for KeyExchangeGroup<'a> {
1840 const NAME: &'static str = "transport:key_exchange_group";
1841 }
1842 #[derive(Clone, Debug)]
1843 #[non_exhaustive]
1844 #[doc = " Packet was skipped with a given reason"]
1845 pub struct PacketSkipped {
1846 pub number: u64,
1847 pub space: KeySpace,
1848 pub reason: PacketSkipReason,
1849 }
1850 #[cfg(any(test, feature = "testing"))]
1851 impl crate::event::snapshot::Fmt for PacketSkipped {
1852 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
1853 let mut fmt = fmt.debug_struct("PacketSkipped");
1854 fmt.field("number", &self.number);
1855 fmt.field("space", &self.space);
1856 fmt.field("reason", &self.reason);
1857 fmt.finish()
1858 }
1859 }
1860 impl Event for PacketSkipped {
1861 const NAME: &'static str = "transport:packet_skipped";
1862 }
1863 #[derive(Clone, Debug)]
1864 #[non_exhaustive]
1865 #[doc = " Packet was sent by a connection"]
1866 pub struct PacketSent {
1867 pub packet_header: PacketHeader,
1868 pub packet_len: usize,
1869 }
1870 #[cfg(any(test, feature = "testing"))]
1871 impl crate::event::snapshot::Fmt for PacketSent {
1872 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
1873 let mut fmt = fmt.debug_struct("PacketSent");
1874 fmt.field("packet_header", &self.packet_header);
1875 fmt.field("packet_len", &self.packet_len);
1876 fmt.finish()
1877 }
1878 }
1879 impl Event for PacketSent {
1880 const NAME: &'static str = "transport:packet_sent";
1881 }
1882 #[derive(Clone, Debug)]
1883 #[non_exhaustive]
1884 #[doc = " Packet was received by a connection"]
1885 pub struct PacketReceived {
1886 pub packet_header: PacketHeader,
1887 }
1888 #[cfg(any(test, feature = "testing"))]
1889 impl crate::event::snapshot::Fmt for PacketReceived {
1890 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
1891 let mut fmt = fmt.debug_struct("PacketReceived");
1892 fmt.field("packet_header", &self.packet_header);
1893 fmt.finish()
1894 }
1895 }
1896 impl Event for PacketReceived {
1897 const NAME: &'static str = "transport:packet_received";
1898 }
1899 #[derive(Clone, Debug)]
1900 #[non_exhaustive]
1901 #[doc = " Active path was updated"]
1902 pub struct ActivePathUpdated<'a> {
1903 pub previous: Path<'a>,
1904 pub active: Path<'a>,
1905 }
1906 #[cfg(any(test, feature = "testing"))]
1907 impl<'a> crate::event::snapshot::Fmt for ActivePathUpdated<'a> {
1908 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
1909 let mut fmt = fmt.debug_struct("ActivePathUpdated");
1910 fmt.field("previous", &self.previous);
1911 fmt.field("active", &self.active);
1912 fmt.finish()
1913 }
1914 }
1915 impl<'a> Event for ActivePathUpdated<'a> {
1916 const NAME: &'static str = "connectivity:active_path_updated";
1917 }
1918 #[derive(Clone, Debug)]
1919 #[non_exhaustive]
1920 #[doc = " A new path was created"]
1921 pub struct PathCreated<'a> {
1922 pub active: Path<'a>,
1923 pub new: Path<'a>,
1924 }
1925 #[cfg(any(test, feature = "testing"))]
1926 impl<'a> crate::event::snapshot::Fmt for PathCreated<'a> {
1927 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
1928 let mut fmt = fmt.debug_struct("PathCreated");
1929 fmt.field("active", &self.active);
1930 fmt.field("new", &self.new);
1931 fmt.finish()
1932 }
1933 }
1934 impl<'a> Event for PathCreated<'a> {
1935 const NAME: &'static str = "transport:path_created";
1936 }
1937 #[derive(Clone, Debug)]
1938 #[non_exhaustive]
1939 #[doc = " Frame was sent"]
1940 pub struct FrameSent {
1941 pub packet_header: PacketHeader,
1942 pub path_id: u64,
1943 pub frame: Frame,
1944 }
1945 #[cfg(any(test, feature = "testing"))]
1946 impl crate::event::snapshot::Fmt for FrameSent {
1947 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
1948 let mut fmt = fmt.debug_struct("FrameSent");
1949 fmt.field("packet_header", &self.packet_header);
1950 fmt.field("path_id", &self.path_id);
1951 fmt.field("frame", &self.frame);
1952 fmt.finish()
1953 }
1954 }
1955 impl Event for FrameSent {
1956 const NAME: &'static str = "transport:frame_sent";
1957 }
1958 #[derive(Clone, Debug)]
1959 #[non_exhaustive]
1960 #[doc = " Frame was received"]
1961 pub struct FrameReceived<'a> {
1962 pub packet_header: PacketHeader,
1963 pub path: Path<'a>,
1964 pub frame: Frame,
1965 }
1966 #[cfg(any(test, feature = "testing"))]
1967 impl<'a> crate::event::snapshot::Fmt for FrameReceived<'a> {
1968 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
1969 let mut fmt = fmt.debug_struct("FrameReceived");
1970 fmt.field("packet_header", &self.packet_header);
1971 fmt.field("path", &self.path);
1972 fmt.field("frame", &self.frame);
1973 fmt.finish()
1974 }
1975 }
1976 impl<'a> Event for FrameReceived<'a> {
1977 const NAME: &'static str = "transport:frame_received";
1978 }
1979 #[derive(Clone, Debug)]
1980 #[non_exhaustive]
1981 #[doc = " A `CONNECTION_CLOSE` frame was received"]
1982 #[doc = ""]
1983 #[doc = " This event includes additional details from the frame, particularly the"]
1984 #[doc = " reason (if provided) the peer closed the connection"]
1985 pub struct ConnectionCloseFrameReceived<'a> {
1986 pub packet_header: PacketHeader,
1987 pub path: Path<'a>,
1988 pub frame: ConnectionCloseFrame<'a>,
1989 }
1990 #[cfg(any(test, feature = "testing"))]
1991 impl<'a> crate::event::snapshot::Fmt for ConnectionCloseFrameReceived<'a> {
1992 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
1993 let mut fmt = fmt.debug_struct("ConnectionCloseFrameReceived");
1994 fmt.field("packet_header", &self.packet_header);
1995 fmt.field("path", &self.path);
1996 fmt.field("frame", &self.frame);
1997 fmt.finish()
1998 }
1999 }
2000 impl<'a> Event for ConnectionCloseFrameReceived<'a> {
2001 const NAME: &'static str = "transport:connection_close_frame_received";
2002 }
2003 #[derive(Clone, Debug)]
2004 #[non_exhaustive]
2005 #[doc = " Packet was lost"]
2006 pub struct PacketLost<'a> {
2007 pub packet_header: PacketHeader,
2008 pub path: Path<'a>,
2009 pub bytes_lost: u16,
2010 pub is_mtu_probe: bool,
2011 }
2012 #[cfg(any(test, feature = "testing"))]
2013 impl<'a> crate::event::snapshot::Fmt for PacketLost<'a> {
2014 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2015 let mut fmt = fmt.debug_struct("PacketLost");
2016 fmt.field("packet_header", &self.packet_header);
2017 fmt.field("path", &self.path);
2018 fmt.field("bytes_lost", &self.bytes_lost);
2019 fmt.field("is_mtu_probe", &self.is_mtu_probe);
2020 fmt.finish()
2021 }
2022 }
2023 impl<'a> Event for PacketLost<'a> {
2024 const NAME: &'static str = "recovery:packet_lost";
2025 }
2026 #[derive(Clone, Debug)]
2027 #[non_exhaustive]
2028 #[doc = " Recovery metrics updated"]
2029 pub struct RecoveryMetrics<'a> {
2030 pub path: Path<'a>,
2031 pub min_rtt: Duration,
2032 pub smoothed_rtt: Duration,
2033 pub latest_rtt: Duration,
2034 pub rtt_variance: Duration,
2035 pub max_ack_delay: Duration,
2036 pub pto_count: u32,
2037 pub congestion_window: u32,
2038 pub bytes_in_flight: u32,
2039 pub congestion_limited: bool,
2040 }
2041 #[cfg(any(test, feature = "testing"))]
2042 impl<'a> crate::event::snapshot::Fmt for RecoveryMetrics<'a> {
2043 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2044 let mut fmt = fmt.debug_struct("RecoveryMetrics");
2045 fmt.field("path", &self.path);
2046 fmt.field("min_rtt", &self.min_rtt);
2047 fmt.field("smoothed_rtt", &self.smoothed_rtt);
2048 fmt.field("latest_rtt", &self.latest_rtt);
2049 fmt.field("rtt_variance", &self.rtt_variance);
2050 fmt.field("max_ack_delay", &self.max_ack_delay);
2051 fmt.field("pto_count", &self.pto_count);
2052 fmt.field("congestion_window", &self.congestion_window);
2053 fmt.field("bytes_in_flight", &self.bytes_in_flight);
2054 fmt.field("congestion_limited", &self.congestion_limited);
2055 fmt.finish()
2056 }
2057 }
2058 impl<'a> Event for RecoveryMetrics<'a> {
2059 const NAME: &'static str = "recovery:metrics_updated";
2060 }
2061 #[derive(Clone, Debug)]
2062 #[non_exhaustive]
2063 #[doc = " Congestion (ECN or packet loss) has occurred"]
2064 pub struct Congestion<'a> {
2065 pub path: Path<'a>,
2066 pub source: CongestionSource,
2067 }
2068 #[cfg(any(test, feature = "testing"))]
2069 impl<'a> crate::event::snapshot::Fmt for Congestion<'a> {
2070 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2071 let mut fmt = fmt.debug_struct("Congestion");
2072 fmt.field("path", &self.path);
2073 fmt.field("source", &self.source);
2074 fmt.finish()
2075 }
2076 }
2077 impl<'a> Event for Congestion<'a> {
2078 const NAME: &'static str = "recovery:congestion";
2079 }
2080 #[derive(Clone, Debug)]
2081 #[non_exhaustive]
2082 #[doc = " Events related to ACK processing"]
2083 #[deprecated(note = "use on_rx_ack_range_dropped event instead")]
2084 #[allow(deprecated)]
2085 pub struct AckProcessed<'a> {
2086 pub action: AckAction,
2087 pub path: Path<'a>,
2088 }
2089 #[cfg(any(test, feature = "testing"))]
2090 #[allow(deprecated)]
2091 impl<'a> crate::event::snapshot::Fmt for AckProcessed<'a> {
2092 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2093 let mut fmt = fmt.debug_struct("AckProcessed");
2094 fmt.field("action", &self.action);
2095 fmt.field("path", &self.path);
2096 fmt.finish()
2097 }
2098 }
2099 #[allow(deprecated)]
2100 impl<'a> Event for AckProcessed<'a> {
2101 const NAME: &'static str = "recovery:ack_processed";
2102 }
2103 #[derive(Clone, Debug)]
2104 #[non_exhaustive]
2105 #[doc = " Ack range for received packets was dropped due to space constraints"]
2106 #[doc = ""]
2107 #[doc = " For the purpose of processing Acks, RX packet numbers are stored as"]
2108 #[doc = " packet_number ranges in an IntervalSet; only lower and upper bounds"]
2109 #[doc = " are stored instead of individual packet_numbers. Ranges are merged"]
2110 #[doc = " when possible so only disjointed ranges are stored."]
2111 #[doc = ""]
2112 #[doc = " When at `capacity`, the lowest packet_number range is dropped."]
2113 pub struct RxAckRangeDropped<'a> {
2114 pub path: Path<'a>,
2115 #[doc = " The packet number range which was dropped"]
2116 pub packet_number_range: core::ops::RangeInclusive<u64>,
2117 #[doc = " The number of disjoint ranges the IntervalSet can store"]
2118 pub capacity: usize,
2119 #[doc = " The store packet_number range in the IntervalSet"]
2120 pub stored_range: core::ops::RangeInclusive<u64>,
2121 }
2122 #[cfg(any(test, feature = "testing"))]
2123 impl<'a> crate::event::snapshot::Fmt for RxAckRangeDropped<'a> {
2124 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2125 let mut fmt = fmt.debug_struct("RxAckRangeDropped");
2126 fmt.field("path", &self.path);
2127 fmt.field("packet_number_range", &self.packet_number_range);
2128 fmt.field("capacity", &self.capacity);
2129 fmt.field("stored_range", &self.stored_range);
2130 fmt.finish()
2131 }
2132 }
2133 impl<'a> Event for RxAckRangeDropped<'a> {
2134 const NAME: &'static str = "recovery:rx_ack_range_dropped";
2135 }
2136 #[derive(Clone, Debug)]
2137 #[non_exhaustive]
2138 #[doc = " ACK range was received"]
2139 pub struct AckRangeReceived<'a> {
2140 pub packet_header: PacketHeader,
2141 pub path: Path<'a>,
2142 pub ack_range: RangeInclusive<u64>,
2143 }
2144 #[cfg(any(test, feature = "testing"))]
2145 impl<'a> crate::event::snapshot::Fmt for AckRangeReceived<'a> {
2146 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2147 let mut fmt = fmt.debug_struct("AckRangeReceived");
2148 fmt.field("packet_header", &self.packet_header);
2149 fmt.field("path", &self.path);
2150 fmt.field("ack_range", &self.ack_range);
2151 fmt.finish()
2152 }
2153 }
2154 impl<'a> Event for AckRangeReceived<'a> {
2155 const NAME: &'static str = "recovery:ack_range_received";
2156 }
2157 #[derive(Clone, Debug)]
2158 #[non_exhaustive]
2159 #[doc = " ACK range was sent"]
2160 pub struct AckRangeSent {
2161 pub packet_header: PacketHeader,
2162 pub path_id: u64,
2163 pub ack_range: RangeInclusive<u64>,
2164 }
2165 #[cfg(any(test, feature = "testing"))]
2166 impl crate::event::snapshot::Fmt for AckRangeSent {
2167 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2168 let mut fmt = fmt.debug_struct("AckRangeSent");
2169 fmt.field("packet_header", &self.packet_header);
2170 fmt.field("path_id", &self.path_id);
2171 fmt.field("ack_range", &self.ack_range);
2172 fmt.finish()
2173 }
2174 }
2175 impl Event for AckRangeSent {
2176 const NAME: &'static str = "recovery:ack_range_sent";
2177 }
2178 #[derive(Clone, Debug)]
2179 #[non_exhaustive]
2180 #[doc = " Packet was dropped with the given reason"]
2181 pub struct PacketDropped<'a> {
2182 pub reason: PacketDropReason<'a>,
2183 }
2184 #[cfg(any(test, feature = "testing"))]
2185 impl<'a> crate::event::snapshot::Fmt for PacketDropped<'a> {
2186 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2187 let mut fmt = fmt.debug_struct("PacketDropped");
2188 fmt.field("reason", &self.reason);
2189 fmt.finish()
2190 }
2191 }
2192 impl<'a> Event for PacketDropped<'a> {
2193 const NAME: &'static str = "transport:packet_dropped";
2194 }
2195 #[derive(Clone, Debug)]
2196 #[non_exhaustive]
2197 #[doc = " Crypto key updated"]
2198 pub struct KeyUpdate {
2199 pub key_type: KeyType,
2200 pub cipher_suite: CipherSuite,
2201 }
2202 #[cfg(any(test, feature = "testing"))]
2203 impl crate::event::snapshot::Fmt for KeyUpdate {
2204 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2205 let mut fmt = fmt.debug_struct("KeyUpdate");
2206 fmt.field("key_type", &self.key_type);
2207 fmt.field("cipher_suite", &self.cipher_suite);
2208 fmt.finish()
2209 }
2210 }
2211 impl Event for KeyUpdate {
2212 const NAME: &'static str = "security:key_update";
2213 }
2214 #[derive(Clone, Debug)]
2215 #[non_exhaustive]
2216 pub struct KeySpaceDiscarded {
2217 pub space: KeySpace,
2218 }
2219 #[cfg(any(test, feature = "testing"))]
2220 impl crate::event::snapshot::Fmt for KeySpaceDiscarded {
2221 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2222 let mut fmt = fmt.debug_struct("KeySpaceDiscarded");
2223 fmt.field("space", &self.space);
2224 fmt.finish()
2225 }
2226 }
2227 impl Event for KeySpaceDiscarded {
2228 const NAME: &'static str = "security:key_space_discarded";
2229 }
2230 #[derive(Clone, Debug)]
2231 #[non_exhaustive]
2232 #[doc = " Connection started"]
2233 pub struct ConnectionStarted<'a> {
2234 pub path: Path<'a>,
2235 }
2236 #[cfg(any(test, feature = "testing"))]
2237 impl<'a> crate::event::snapshot::Fmt for ConnectionStarted<'a> {
2238 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2239 let mut fmt = fmt.debug_struct("ConnectionStarted");
2240 fmt.field("path", &self.path);
2241 fmt.finish()
2242 }
2243 }
2244 impl<'a> Event for ConnectionStarted<'a> {
2245 const NAME: &'static str = "connectivity:connection_started";
2246 }
2247 #[derive(Clone, Debug)]
2248 #[non_exhaustive]
2249 #[doc = " Duplicate packet received"]
2250 pub struct DuplicatePacket<'a> {
2251 pub packet_header: PacketHeader,
2252 pub path: Path<'a>,
2253 pub error: DuplicatePacketError,
2254 }
2255 #[cfg(any(test, feature = "testing"))]
2256 impl<'a> crate::event::snapshot::Fmt for DuplicatePacket<'a> {
2257 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2258 let mut fmt = fmt.debug_struct("DuplicatePacket");
2259 fmt.field("packet_header", &self.packet_header);
2260 fmt.field("path", &self.path);
2261 fmt.field("error", &self.error);
2262 fmt.finish()
2263 }
2264 }
2265 impl<'a> Event for DuplicatePacket<'a> {
2266 const NAME: &'static str = "transport:duplicate_packet";
2267 }
2268 #[derive(Clone, Debug)]
2269 #[non_exhaustive]
2270 #[doc = " Transport parameters received by connection"]
2271 pub struct TransportParametersReceived<'a> {
2272 pub transport_parameters: TransportParameters<'a>,
2273 }
2274 #[cfg(any(test, feature = "testing"))]
2275 impl<'a> crate::event::snapshot::Fmt for TransportParametersReceived<'a> {
2276 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2277 let mut fmt = fmt.debug_struct("TransportParametersReceived");
2278 fmt.field("transport_parameters", &self.transport_parameters);
2279 fmt.finish()
2280 }
2281 }
2282 impl<'a> Event for TransportParametersReceived<'a> {
2283 const NAME: &'static str = "transport:transport_parameters_received";
2284 }
2285 #[derive(Clone, Debug)]
2286 #[non_exhaustive]
2287 #[doc = " Datagram sent by a connection"]
2288 pub struct DatagramSent {
2289 pub len: u16,
2290 #[doc = " The GSO offset at which this datagram was written"]
2291 #[doc = ""]
2292 #[doc = " If this value is greater than 0, it indicates that this datagram has been sent with other"]
2293 #[doc = " segments in a single buffer."]
2294 #[doc = ""]
2295 #[doc = " See the [Linux kernel documentation](https://www.kernel.org/doc/html/latest/networking/segmentation-offloads.html#generic-segmentation-offload) for more details."]
2296 pub gso_offset: usize,
2297 }
2298 #[cfg(any(test, feature = "testing"))]
2299 impl crate::event::snapshot::Fmt for DatagramSent {
2300 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2301 let mut fmt = fmt.debug_struct("DatagramSent");
2302 fmt.field("len", &self.len);
2303 fmt.field("gso_offset", &self.gso_offset);
2304 fmt.finish()
2305 }
2306 }
2307 impl Event for DatagramSent {
2308 const NAME: &'static str = "transport:datagram_sent";
2309 }
2310 #[derive(Clone, Debug)]
2311 #[non_exhaustive]
2312 #[doc = " Datagram received by a connection"]
2313 pub struct DatagramReceived {
2314 pub len: u16,
2315 }
2316 #[cfg(any(test, feature = "testing"))]
2317 impl crate::event::snapshot::Fmt for DatagramReceived {
2318 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2319 let mut fmt = fmt.debug_struct("DatagramReceived");
2320 fmt.field("len", &self.len);
2321 fmt.finish()
2322 }
2323 }
2324 impl Event for DatagramReceived {
2325 const NAME: &'static str = "transport:datagram_received";
2326 }
2327 #[derive(Clone, Debug)]
2328 #[non_exhaustive]
2329 #[doc = " Datagram dropped by a connection"]
2330 pub struct DatagramDropped<'a> {
2331 pub local_addr: SocketAddress<'a>,
2332 pub remote_addr: SocketAddress<'a>,
2333 pub destination_cid: ConnectionId<'a>,
2334 pub source_cid: Option<ConnectionId<'a>>,
2335 pub len: u16,
2336 pub reason: DatagramDropReason,
2337 }
2338 #[cfg(any(test, feature = "testing"))]
2339 impl<'a> crate::event::snapshot::Fmt for DatagramDropped<'a> {
2340 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2341 let mut fmt = fmt.debug_struct("DatagramDropped");
2342 fmt.field("local_addr", &self.local_addr);
2343 fmt.field("remote_addr", &self.remote_addr);
2344 fmt.field("destination_cid", &self.destination_cid);
2345 fmt.field("source_cid", &self.source_cid);
2346 fmt.field("len", &self.len);
2347 fmt.field("reason", &self.reason);
2348 fmt.finish()
2349 }
2350 }
2351 impl<'a> Event for DatagramDropped<'a> {
2352 const NAME: &'static str = "transport:datagram_dropped";
2353 }
2354 #[derive(Clone, Debug)]
2355 #[non_exhaustive]
2356 #[doc = " The remote address was changed before the handshake was complete"]
2357 pub struct HandshakeRemoteAddressChangeObserved<'a> {
2358 pub local_addr: SocketAddress<'a>,
2359 #[doc = " The newly observed remote address"]
2360 pub remote_addr: SocketAddress<'a>,
2361 #[doc = " The remote address established from the initial packet"]
2362 pub initial_remote_addr: SocketAddress<'a>,
2363 }
2364 #[cfg(any(test, feature = "testing"))]
2365 impl<'a> crate::event::snapshot::Fmt for HandshakeRemoteAddressChangeObserved<'a> {
2366 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2367 let mut fmt = fmt.debug_struct("HandshakeRemoteAddressChangeObserved");
2368 fmt.field("local_addr", &self.local_addr);
2369 fmt.field("remote_addr", &self.remote_addr);
2370 fmt.field("initial_remote_addr", &self.initial_remote_addr);
2371 fmt.finish()
2372 }
2373 }
2374 impl<'a> Event for HandshakeRemoteAddressChangeObserved<'a> {
2375 const NAME: &'static str = "transport:handshake_remote_address_change_observed";
2376 }
2377 #[derive(Clone, Debug)]
2378 #[non_exhaustive]
2379 #[doc = " ConnectionId updated"]
2380 pub struct ConnectionIdUpdated<'a> {
2381 pub path_id: u64,
2382 #[doc = " The endpoint that updated its connection id"]
2383 pub cid_consumer: crate::endpoint::Location,
2384 pub previous: ConnectionId<'a>,
2385 pub current: ConnectionId<'a>,
2386 }
2387 #[cfg(any(test, feature = "testing"))]
2388 impl<'a> crate::event::snapshot::Fmt for ConnectionIdUpdated<'a> {
2389 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2390 let mut fmt = fmt.debug_struct("ConnectionIdUpdated");
2391 fmt.field("path_id", &self.path_id);
2392 fmt.field("cid_consumer", &self.cid_consumer);
2393 fmt.field("previous", &self.previous);
2394 fmt.field("current", &self.current);
2395 fmt.finish()
2396 }
2397 }
2398 impl<'a> Event for ConnectionIdUpdated<'a> {
2399 const NAME: &'static str = "connectivity:connection_id_updated";
2400 }
2401 #[derive(Clone, Debug)]
2402 #[non_exhaustive]
2403 pub struct EcnStateChanged<'a> {
2404 pub path: Path<'a>,
2405 pub state: EcnState,
2406 }
2407 #[cfg(any(test, feature = "testing"))]
2408 impl<'a> crate::event::snapshot::Fmt for EcnStateChanged<'a> {
2409 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2410 let mut fmt = fmt.debug_struct("EcnStateChanged");
2411 fmt.field("path", &self.path);
2412 fmt.field("state", &self.state);
2413 fmt.finish()
2414 }
2415 }
2416 impl<'a> Event for EcnStateChanged<'a> {
2417 const NAME: &'static str = "recovery:ecn_state_changed";
2418 }
2419 #[derive(Clone, Debug)]
2420 #[non_exhaustive]
2421 pub struct ConnectionMigrationDenied {
2422 pub reason: MigrationDenyReason,
2423 }
2424 #[cfg(any(test, feature = "testing"))]
2425 impl crate::event::snapshot::Fmt for ConnectionMigrationDenied {
2426 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2427 let mut fmt = fmt.debug_struct("ConnectionMigrationDenied");
2428 fmt.field("reason", &self.reason);
2429 fmt.finish()
2430 }
2431 }
2432 impl Event for ConnectionMigrationDenied {
2433 const NAME: &'static str = "connectivity:connection_migration_denied";
2434 }
2435 #[derive(Clone, Debug)]
2436 #[non_exhaustive]
2437 pub struct HandshakeStatusUpdated {
2438 pub status: HandshakeStatus,
2439 }
2440 #[cfg(any(test, feature = "testing"))]
2441 impl crate::event::snapshot::Fmt for HandshakeStatusUpdated {
2442 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2443 let mut fmt = fmt.debug_struct("HandshakeStatusUpdated");
2444 fmt.field("status", &self.status);
2445 fmt.finish()
2446 }
2447 }
2448 impl Event for HandshakeStatusUpdated {
2449 const NAME: &'static str = "connectivity:handshake_status_updated";
2450 }
2451 #[derive(Clone, Debug)]
2452 #[non_exhaustive]
2453 pub struct TlsExporterReady<'a> {
2454 pub session: crate::event::TlsSession<'a>,
2455 }
2456 #[cfg(any(test, feature = "testing"))]
2457 impl<'a> crate::event::snapshot::Fmt for TlsExporterReady<'a> {
2458 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2459 let mut fmt = fmt.debug_struct("TlsExporterReady");
2460 fmt.field("session", &self.session);
2461 fmt.finish()
2462 }
2463 }
2464 impl<'a> Event for TlsExporterReady<'a> {
2465 const NAME: &'static str = "connectivity:tls_exporter_ready";
2466 }
2467 #[derive(Clone, Debug)]
2468 #[non_exhaustive]
2469 pub struct TlsHandshakeFailed<'a> {
2470 pub session: crate::event::TlsSession<'a>,
2471 }
2472 #[cfg(any(test, feature = "testing"))]
2473 impl<'a> crate::event::snapshot::Fmt for TlsHandshakeFailed<'a> {
2474 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2475 let mut fmt = fmt.debug_struct("TlsHandshakeFailed");
2476 fmt.field("session", &self.session);
2477 fmt.finish()
2478 }
2479 }
2480 impl<'a> Event for TlsHandshakeFailed<'a> {
2481 const NAME: &'static str = "connectivity:tls_handshake_failed";
2482 }
2483 #[derive(Clone, Debug)]
2484 #[non_exhaustive]
2485 #[doc = " Path challenge updated"]
2486 pub struct PathChallengeUpdated<'a> {
2487 pub path_challenge_status: PathChallengeStatus,
2488 pub path: Path<'a>,
2489 pub challenge_data: &'a [u8],
2490 }
2491 #[cfg(any(test, feature = "testing"))]
2492 impl<'a> crate::event::snapshot::Fmt for PathChallengeUpdated<'a> {
2493 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2494 let mut fmt = fmt.debug_struct("PathChallengeUpdated");
2495 fmt.field("path_challenge_status", &self.path_challenge_status);
2496 fmt.field("path", &self.path);
2497 fmt.field("challenge_data", &self.challenge_data);
2498 fmt.finish()
2499 }
2500 }
2501 impl<'a> Event for PathChallengeUpdated<'a> {
2502 const NAME: &'static str = "connectivity:path_challenge_updated";
2503 }
2504 #[derive(Clone, Debug)]
2505 #[non_exhaustive]
2506 pub struct TlsClientHello<'a> {
2507 pub payload: &'a [&'a [u8]],
2508 }
2509 #[cfg(any(test, feature = "testing"))]
2510 impl<'a> crate::event::snapshot::Fmt for TlsClientHello<'a> {
2511 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2512 let mut fmt = fmt.debug_struct("TlsClientHello");
2513 fmt.field("payload", &self.payload);
2514 fmt.finish()
2515 }
2516 }
2517 impl<'a> Event for TlsClientHello<'a> {
2518 const NAME: &'static str = "tls:client_hello";
2519 }
2520 #[derive(Clone, Debug)]
2521 #[non_exhaustive]
2522 pub struct TlsServerHello<'a> {
2523 pub payload: &'a [&'a [u8]],
2524 }
2525 #[cfg(any(test, feature = "testing"))]
2526 impl<'a> crate::event::snapshot::Fmt for TlsServerHello<'a> {
2527 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2528 let mut fmt = fmt.debug_struct("TlsServerHello");
2529 fmt.field("payload", &self.payload);
2530 fmt.finish()
2531 }
2532 }
2533 impl<'a> Event for TlsServerHello<'a> {
2534 const NAME: &'static str = "tls:server_hello";
2535 }
2536 #[derive(Clone, Debug)]
2537 #[non_exhaustive]
2538 pub struct RxStreamProgress {
2539 pub bytes: usize,
2540 }
2541 #[cfg(any(test, feature = "testing"))]
2542 impl crate::event::snapshot::Fmt for RxStreamProgress {
2543 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2544 let mut fmt = fmt.debug_struct("RxStreamProgress");
2545 fmt.field("bytes", &self.bytes);
2546 fmt.finish()
2547 }
2548 }
2549 impl Event for RxStreamProgress {
2550 const NAME: &'static str = "transport:rx_stream_progress";
2551 }
2552 #[derive(Clone, Debug)]
2553 #[non_exhaustive]
2554 pub struct TxStreamProgress {
2555 pub bytes: usize,
2556 }
2557 #[cfg(any(test, feature = "testing"))]
2558 impl crate::event::snapshot::Fmt for TxStreamProgress {
2559 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2560 let mut fmt = fmt.debug_struct("TxStreamProgress");
2561 fmt.field("bytes", &self.bytes);
2562 fmt.finish()
2563 }
2564 }
2565 impl Event for TxStreamProgress {
2566 const NAME: &'static str = "transport:tx_stream_progress";
2567 }
2568 #[derive(Clone, Debug)]
2569 #[non_exhaustive]
2570 pub struct KeepAliveTimerExpired {
2571 pub timeout: Duration,
2572 }
2573 #[cfg(any(test, feature = "testing"))]
2574 impl crate::event::snapshot::Fmt for KeepAliveTimerExpired {
2575 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2576 let mut fmt = fmt.debug_struct("KeepAliveTimerExpired");
2577 fmt.field("timeout", &self.timeout);
2578 fmt.finish()
2579 }
2580 }
2581 impl Event for KeepAliveTimerExpired {
2582 const NAME: &'static str = "connectivity::keep_alive_timer_expired";
2583 }
2584 #[derive(Clone, Debug)]
2585 #[non_exhaustive]
2586 #[doc = " The maximum transmission unit (MTU) and/or MTU probing status for the path has changed"]
2587 pub struct MtuUpdated {
2588 pub path_id: u64,
2589 #[doc = " The maximum QUIC datagram size, not including UDP and IP headers"]
2590 pub mtu: u16,
2591 pub cause: MtuUpdatedCause,
2592 #[doc = " The search for the maximum MTU has completed for now"]
2593 pub search_complete: bool,
2594 }
2595 #[cfg(any(test, feature = "testing"))]
2596 impl crate::event::snapshot::Fmt for MtuUpdated {
2597 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2598 let mut fmt = fmt.debug_struct("MtuUpdated");
2599 fmt.field("path_id", &self.path_id);
2600 fmt.field("mtu", &self.mtu);
2601 fmt.field("cause", &self.cause);
2602 fmt.field("search_complete", &self.search_complete);
2603 fmt.finish()
2604 }
2605 }
2606 impl Event for MtuUpdated {
2607 const NAME: &'static str = "connectivity:mtu_updated";
2608 }
2609 #[derive(Clone, Debug)]
2610 #[non_exhaustive]
2611 #[doc = " The slow start congestion controller state has been exited"]
2612 pub struct SlowStartExited {
2613 pub path_id: u64,
2614 pub cause: SlowStartExitCause,
2615 pub congestion_window: u32,
2616 }
2617 #[cfg(any(test, feature = "testing"))]
2618 impl crate::event::snapshot::Fmt for SlowStartExited {
2619 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2620 let mut fmt = fmt.debug_struct("SlowStartExited");
2621 fmt.field("path_id", &self.path_id);
2622 fmt.field("cause", &self.cause);
2623 fmt.field("congestion_window", &self.congestion_window);
2624 fmt.finish()
2625 }
2626 }
2627 impl Event for SlowStartExited {
2628 const NAME: &'static str = "recovery:slow_start_exited";
2629 }
2630 #[derive(Clone, Debug)]
2631 #[non_exhaustive]
2632 #[doc = " A new delivery rate sample has been generated"]
2633 #[doc = " Note: This event is only recorded for congestion controllers that support"]
2634 #[doc = " bandwidth estimates, such as BBR"]
2635 pub struct DeliveryRateSampled {
2636 pub path_id: u64,
2637 pub rate_sample: RateSample,
2638 }
2639 #[cfg(any(test, feature = "testing"))]
2640 impl crate::event::snapshot::Fmt for DeliveryRateSampled {
2641 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2642 let mut fmt = fmt.debug_struct("DeliveryRateSampled");
2643 fmt.field("path_id", &self.path_id);
2644 fmt.field("rate_sample", &self.rate_sample);
2645 fmt.finish()
2646 }
2647 }
2648 impl Event for DeliveryRateSampled {
2649 const NAME: &'static str = "recovery:delivery_rate_sampled";
2650 }
2651 #[derive(Clone, Debug)]
2652 #[non_exhaustive]
2653 #[doc = " The pacing rate has been updated"]
2654 pub struct PacingRateUpdated {
2655 pub path_id: u64,
2656 pub bytes_per_second: u64,
2657 pub burst_size: u32,
2658 pub pacing_gain: f32,
2659 }
2660 #[cfg(any(test, feature = "testing"))]
2661 impl crate::event::snapshot::Fmt for PacingRateUpdated {
2662 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2663 let mut fmt = fmt.debug_struct("PacingRateUpdated");
2664 fmt.field("path_id", &self.path_id);
2665 fmt.field("bytes_per_second", &self.bytes_per_second);
2666 fmt.field("burst_size", &self.burst_size);
2667 fmt.field("pacing_gain", &self.pacing_gain);
2668 fmt.finish()
2669 }
2670 }
2671 impl Event for PacingRateUpdated {
2672 const NAME: &'static str = "recovery:pacing_rate_updated";
2673 }
2674 #[derive(Clone, Debug)]
2675 #[non_exhaustive]
2676 #[doc = " The BBR state has changed"]
2677 pub struct BbrStateChanged {
2678 pub path_id: u64,
2679 pub state: BbrState,
2680 }
2681 #[cfg(any(test, feature = "testing"))]
2682 impl crate::event::snapshot::Fmt for BbrStateChanged {
2683 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2684 let mut fmt = fmt.debug_struct("BbrStateChanged");
2685 fmt.field("path_id", &self.path_id);
2686 fmt.field("state", &self.state);
2687 fmt.finish()
2688 }
2689 }
2690 impl Event for BbrStateChanged {
2691 const NAME: &'static str = "recovery:bbr_state_changed";
2692 }
2693 #[derive(Clone, Debug)]
2694 #[non_exhaustive]
2695 #[doc = " The DC state has changed"]
2696 pub struct DcStateChanged {
2697 pub state: DcState,
2698 }
2699 #[cfg(any(test, feature = "testing"))]
2700 impl crate::event::snapshot::Fmt for DcStateChanged {
2701 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2702 let mut fmt = fmt.debug_struct("DcStateChanged");
2703 fmt.field("state", &self.state);
2704 fmt.finish()
2705 }
2706 }
2707 impl Event for DcStateChanged {
2708 const NAME: &'static str = "transport:dc_state_changed";
2709 }
2710 #[derive(Clone, Debug)]
2711 #[non_exhaustive]
2712 #[doc = " The DC path has been created"]
2713 pub struct DcPathCreated<'a> {
2714 #[doc = " This is the dc::Path struct, it's just type-erased. But if an event subscriber knows the"]
2715 #[doc = " type they can downcast."]
2716 pub path: &'a (dyn core::any::Any + Send + 'static),
2717 }
2718 #[cfg(any(test, feature = "testing"))]
2719 impl<'a> crate::event::snapshot::Fmt for DcPathCreated<'a> {
2720 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2721 let mut fmt = fmt.debug_struct("DcPathCreated");
2722 fmt.field("path", &self.path);
2723 fmt.finish()
2724 }
2725 }
2726 impl<'a> Event for DcPathCreated<'a> {
2727 const NAME: &'static str = "transport:dc_path_created";
2728 }
2729 #[derive(Clone, Debug)]
2730 #[non_exhaustive]
2731 #[doc = " Connection closed"]
2732 pub struct ConnectionClosed {
2733 pub error: crate::connection::Error,
2734 }
2735 #[cfg(any(test, feature = "testing"))]
2736 impl crate::event::snapshot::Fmt for ConnectionClosed {
2737 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2738 let mut fmt = fmt.debug_struct("ConnectionClosed");
2739 fmt.field("error", &self.error);
2740 fmt.finish()
2741 }
2742 }
2743 impl Event for ConnectionClosed {
2744 const NAME: &'static str = "connectivity:connection_closed";
2745 }
2746 #[derive(Clone, Debug)]
2747 #[non_exhaustive]
2748 #[doc = " QUIC version"]
2749 pub struct VersionInformation<'a> {
2750 pub server_versions: &'a [u32],
2751 pub client_versions: &'a [u32],
2752 pub chosen_version: Option<u32>,
2753 }
2754 #[cfg(any(test, feature = "testing"))]
2755 impl<'a> crate::event::snapshot::Fmt for VersionInformation<'a> {
2756 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2757 let mut fmt = fmt.debug_struct("VersionInformation");
2758 fmt.field("server_versions", &self.server_versions);
2759 fmt.field("client_versions", &self.client_versions);
2760 fmt.field("chosen_version", &self.chosen_version);
2761 fmt.finish()
2762 }
2763 }
2764 impl<'a> Event for VersionInformation<'a> {
2765 const NAME: &'static str = "transport::version_information";
2766 }
2767 #[derive(Clone, Debug)]
2768 #[non_exhaustive]
2769 #[doc = " Packet was sent by the endpoint"]
2770 pub struct EndpointPacketSent {
2771 pub packet_header: PacketHeader,
2772 }
2773 #[cfg(any(test, feature = "testing"))]
2774 impl crate::event::snapshot::Fmt for EndpointPacketSent {
2775 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2776 let mut fmt = fmt.debug_struct("EndpointPacketSent");
2777 fmt.field("packet_header", &self.packet_header);
2778 fmt.finish()
2779 }
2780 }
2781 impl Event for EndpointPacketSent {
2782 const NAME: &'static str = "transport:packet_sent";
2783 }
2784 #[derive(Clone, Debug)]
2785 #[non_exhaustive]
2786 #[doc = " Packet was received by the endpoint"]
2787 pub struct EndpointPacketReceived {
2788 pub packet_header: PacketHeader,
2789 }
2790 #[cfg(any(test, feature = "testing"))]
2791 impl crate::event::snapshot::Fmt for EndpointPacketReceived {
2792 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2793 let mut fmt = fmt.debug_struct("EndpointPacketReceived");
2794 fmt.field("packet_header", &self.packet_header);
2795 fmt.finish()
2796 }
2797 }
2798 impl Event for EndpointPacketReceived {
2799 const NAME: &'static str = "transport:packet_received";
2800 }
2801 #[derive(Clone, Debug)]
2802 #[non_exhaustive]
2803 #[doc = " Datagram sent by the endpoint"]
2804 pub struct EndpointDatagramSent {
2805 pub len: u16,
2806 #[doc = " The GSO offset at which this datagram was written"]
2807 #[doc = ""]
2808 #[doc = " If this value is greater than 0, it indicates that this datagram has been sent with other"]
2809 #[doc = " segments in a single buffer."]
2810 #[doc = ""]
2811 #[doc = " See the [Linux kernel documentation](https://www.kernel.org/doc/html/latest/networking/segmentation-offloads.html#generic-segmentation-offload) for more details."]
2812 pub gso_offset: usize,
2813 }
2814 #[cfg(any(test, feature = "testing"))]
2815 impl crate::event::snapshot::Fmt for EndpointDatagramSent {
2816 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2817 let mut fmt = fmt.debug_struct("EndpointDatagramSent");
2818 fmt.field("len", &self.len);
2819 fmt.field("gso_offset", &self.gso_offset);
2820 fmt.finish()
2821 }
2822 }
2823 impl Event for EndpointDatagramSent {
2824 const NAME: &'static str = "transport:datagram_sent";
2825 }
2826 #[derive(Clone, Debug)]
2827 #[non_exhaustive]
2828 #[doc = " Datagram received by the endpoint"]
2829 pub struct EndpointDatagramReceived {
2830 pub len: u16,
2831 }
2832 #[cfg(any(test, feature = "testing"))]
2833 impl crate::event::snapshot::Fmt for EndpointDatagramReceived {
2834 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2835 let mut fmt = fmt.debug_struct("EndpointDatagramReceived");
2836 fmt.field("len", &self.len);
2837 fmt.finish()
2838 }
2839 }
2840 impl Event for EndpointDatagramReceived {
2841 const NAME: &'static str = "transport:datagram_received";
2842 }
2843 #[derive(Clone, Debug)]
2844 #[non_exhaustive]
2845 #[doc = " Datagram dropped by the endpoint"]
2846 pub struct EndpointDatagramDropped {
2847 pub len: u16,
2848 pub reason: DatagramDropReason,
2849 }
2850 #[cfg(any(test, feature = "testing"))]
2851 impl crate::event::snapshot::Fmt for EndpointDatagramDropped {
2852 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2853 let mut fmt = fmt.debug_struct("EndpointDatagramDropped");
2854 fmt.field("len", &self.len);
2855 fmt.field("reason", &self.reason);
2856 fmt.finish()
2857 }
2858 }
2859 impl Event for EndpointDatagramDropped {
2860 const NAME: &'static str = "transport:datagram_dropped";
2861 }
2862 #[derive(Clone, Debug)]
2863 #[non_exhaustive]
2864 pub struct EndpointConnectionAttemptFailed {
2865 pub error: crate::connection::Error,
2866 }
2867 #[cfg(any(test, feature = "testing"))]
2868 impl crate::event::snapshot::Fmt for EndpointConnectionAttemptFailed {
2869 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2870 let mut fmt = fmt.debug_struct("EndpointConnectionAttemptFailed");
2871 fmt.field("error", &self.error);
2872 fmt.finish()
2873 }
2874 }
2875 impl Event for EndpointConnectionAttemptFailed {
2876 const NAME: &'static str = "transport:connection_attempt_failed";
2877 }
2878 #[derive(Clone, Debug)]
2879 #[non_exhaustive]
2880 pub struct EndpointConnectionAttemptDeduplicated {
2881 #[doc = " The internal connection ID this deduplicated with."]
2882 pub connection_id: u64,
2883 pub already_open: bool,
2884 }
2885 #[cfg(any(test, feature = "testing"))]
2886 impl crate::event::snapshot::Fmt for EndpointConnectionAttemptDeduplicated {
2887 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2888 let mut fmt = fmt.debug_struct("EndpointConnectionAttemptDeduplicated");
2889 fmt.field("connection_id", &self.connection_id);
2890 fmt.field("already_open", &self.already_open);
2891 fmt.finish()
2892 }
2893 }
2894 impl Event for EndpointConnectionAttemptDeduplicated {
2895 const NAME: &'static str = "endpoint:connection_attempt_deduplicated";
2896 }
2897 #[derive(Clone, Debug)]
2898 #[non_exhaustive]
2899 #[doc = " Emitted when the platform sends at least one packet"]
2900 pub struct PlatformTx {
2901 #[doc = " The number of packets sent"]
2902 pub count: usize,
2903 #[doc = " The number of syscalls performed"]
2904 pub syscalls: usize,
2905 #[doc = " The number of syscalls that got blocked"]
2906 pub blocked_syscalls: usize,
2907 #[doc = " The total number of errors encountered since the last event"]
2908 pub total_errors: usize,
2909 #[doc = " The number of specific error codes dropped"]
2910 #[doc = ""]
2911 #[doc = " This can happen when a burst of errors exceeds the capacity of the recorder"]
2912 pub dropped_errors: usize,
2913 }
2914 #[cfg(any(test, feature = "testing"))]
2915 impl crate::event::snapshot::Fmt for PlatformTx {
2916 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2917 let mut fmt = fmt.debug_struct("PlatformTx");
2918 fmt.field("count", &self.count);
2919 fmt.field("syscalls", &self.syscalls);
2920 fmt.field("blocked_syscalls", &self.blocked_syscalls);
2921 fmt.field("total_errors", &self.total_errors);
2922 fmt.field("dropped_errors", &self.dropped_errors);
2923 fmt.finish()
2924 }
2925 }
2926 impl Event for PlatformTx {
2927 const NAME: &'static str = "platform:tx";
2928 }
2929 #[derive(Clone, Debug)]
2930 #[non_exhaustive]
2931 #[doc = " Emitted when the platform returns an error while sending datagrams"]
2932 pub struct PlatformTxError {
2933 #[doc = " The error code returned by the platform"]
2934 pub errno: i32,
2935 }
2936 #[cfg(any(test, feature = "testing"))]
2937 impl crate::event::snapshot::Fmt for PlatformTxError {
2938 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2939 let mut fmt = fmt.debug_struct("PlatformTxError");
2940 fmt.field("errno", &self.errno);
2941 fmt.finish()
2942 }
2943 }
2944 impl Event for PlatformTxError {
2945 const NAME: &'static str = "platform:tx_error";
2946 }
2947 #[derive(Clone, Debug)]
2948 #[non_exhaustive]
2949 #[doc = " Emitted when the platform receives at least one packet"]
2950 pub struct PlatformRx {
2951 #[doc = " The number of packets received"]
2952 pub count: usize,
2953 #[doc = " The number of syscalls performed"]
2954 pub syscalls: usize,
2955 #[doc = " The number of syscalls that got blocked"]
2956 pub blocked_syscalls: usize,
2957 #[doc = " The total number of errors encountered since the last event"]
2958 pub total_errors: usize,
2959 #[doc = " The number of specific error codes dropped"]
2960 #[doc = ""]
2961 #[doc = " This can happen when a burst of errors exceeds the capacity of the recorder"]
2962 pub dropped_errors: usize,
2963 }
2964 #[cfg(any(test, feature = "testing"))]
2965 impl crate::event::snapshot::Fmt for PlatformRx {
2966 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2967 let mut fmt = fmt.debug_struct("PlatformRx");
2968 fmt.field("count", &self.count);
2969 fmt.field("syscalls", &self.syscalls);
2970 fmt.field("blocked_syscalls", &self.blocked_syscalls);
2971 fmt.field("total_errors", &self.total_errors);
2972 fmt.field("dropped_errors", &self.dropped_errors);
2973 fmt.finish()
2974 }
2975 }
2976 impl Event for PlatformRx {
2977 const NAME: &'static str = "platform:rx";
2978 }
2979 #[derive(Clone, Debug)]
2980 #[non_exhaustive]
2981 #[doc = " Emitted when the platform returns an error while receiving datagrams"]
2982 pub struct PlatformRxError {
2983 #[doc = " The error code returned by the platform"]
2984 pub errno: i32,
2985 }
2986 #[cfg(any(test, feature = "testing"))]
2987 impl crate::event::snapshot::Fmt for PlatformRxError {
2988 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
2989 let mut fmt = fmt.debug_struct("PlatformRxError");
2990 fmt.field("errno", &self.errno);
2991 fmt.finish()
2992 }
2993 }
2994 impl Event for PlatformRxError {
2995 const NAME: &'static str = "platform:rx_error";
2996 }
2997 #[derive(Clone, Debug)]
2998 #[non_exhaustive]
2999 #[doc = " Emitted when a platform feature is configured"]
3000 pub struct PlatformFeatureConfigured {
3001 pub configuration: PlatformFeatureConfiguration,
3002 }
3003 #[cfg(any(test, feature = "testing"))]
3004 impl crate::event::snapshot::Fmt for PlatformFeatureConfigured {
3005 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
3006 let mut fmt = fmt.debug_struct("PlatformFeatureConfigured");
3007 fmt.field("configuration", &self.configuration);
3008 fmt.finish()
3009 }
3010 }
3011 impl Event for PlatformFeatureConfigured {
3012 const NAME: &'static str = "platform:feature_configured";
3013 }
3014 #[derive(Clone, Debug)]
3015 #[non_exhaustive]
3016 pub struct PlatformEventLoopWakeup {
3017 pub timeout_expired: bool,
3018 pub rx_ready: bool,
3019 pub tx_ready: bool,
3020 pub application_wakeup: bool,
3021 }
3022 #[cfg(any(test, feature = "testing"))]
3023 impl crate::event::snapshot::Fmt for PlatformEventLoopWakeup {
3024 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
3025 let mut fmt = fmt.debug_struct("PlatformEventLoopWakeup");
3026 fmt.field("timeout_expired", &self.timeout_expired);
3027 fmt.field("rx_ready", &self.rx_ready);
3028 fmt.field("tx_ready", &self.tx_ready);
3029 fmt.field("application_wakeup", &self.application_wakeup);
3030 fmt.finish()
3031 }
3032 }
3033 impl Event for PlatformEventLoopWakeup {
3034 const NAME: &'static str = "platform:event_loop_wakeup";
3035 }
3036 #[derive(Clone, Debug)]
3037 #[non_exhaustive]
3038 pub struct PlatformEventLoopSleep {
3039 #[doc = " The next time at which the event loop will wake"]
3040 pub timeout: Option<core::time::Duration>,
3041 #[doc = " The amount of time spent processing endpoint events in a single event loop"]
3042 pub processing_duration: core::time::Duration,
3043 }
3044 #[cfg(any(test, feature = "testing"))]
3045 impl crate::event::snapshot::Fmt for PlatformEventLoopSleep {
3046 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
3047 let mut fmt = fmt.debug_struct("PlatformEventLoopSleep");
3048 fmt.field("timeout", &self.timeout);
3049 fmt.field("processing_duration", &self.processing_duration);
3050 fmt.finish()
3051 }
3052 }
3053 impl Event for PlatformEventLoopSleep {
3054 const NAME: &'static str = "platform:event_loop_sleep";
3055 }
3056 #[derive(Clone, Debug)]
3057 #[non_exhaustive]
3058 pub struct PlatformEventLoopStarted<'a> {
3059 #[doc = " The local address of the socket"]
3060 pub local_address: SocketAddress<'a>,
3061 }
3062 #[cfg(any(test, feature = "testing"))]
3063 impl<'a> crate::event::snapshot::Fmt for PlatformEventLoopStarted<'a> {
3064 fn fmt(&self, fmt: &mut core::fmt::Formatter) -> core::fmt::Result {
3065 let mut fmt = fmt.debug_struct("PlatformEventLoopStarted");
3066 fmt.field("local_address", &self.local_address);
3067 fmt.finish()
3068 }
3069 }
3070 impl<'a> Event for PlatformEventLoopStarted<'a> {
3071 const NAME: &'static str = "platform:started";
3072 }
3073 #[derive(Clone, Debug)]
3074 #[non_exhaustive]
3075 pub enum PlatformFeatureConfiguration {
3076 #[non_exhaustive]
3077 #[doc = " Emitted when segment offload was configured"]
3078 Gso {
3079 #[doc = " The maximum number of segments that can be sent in a single GSO packet"]
3080 #[doc = ""]
3081 #[doc = " If this value not greater than 1, GSO is disabled."]
3082 max_segments: usize,
3083 },
3084 #[non_exhaustive]
3085 #[doc = " Emitted when receive segment offload was configured"]
3086 Gro { enabled: bool },
3087 #[non_exhaustive]
3088 #[doc = " Emitted when ECN support is configured"]
3089 Ecn { enabled: bool },
3090 #[non_exhaustive]
3091 #[doc = " Emitted when the base maximum transmission unit is configured"]
3092 BaseMtu { mtu: u16 },
3093 #[non_exhaustive]
3094 #[doc = " Emitted when the initial maximum transmission unit is configured"]
3095 InitialMtu { mtu: u16 },
3096 #[non_exhaustive]
3097 #[doc = " Emitted when the max maximum transmission unit is configured"]
3098 MaxMtu { mtu: u16 },
3099 }
3100 impl aggregate::AsVariant for PlatformFeatureConfiguration {
3101 const VARIANTS: &'static [aggregate::info::Variant] = &[
3102 aggregate::info::variant::Builder {
3103 name: aggregate::info::Str::new("GSO\0"),
3104 id: 0usize,
3105 }
3106 .build(),
3107 aggregate::info::variant::Builder {
3108 name: aggregate::info::Str::new("GRO\0"),
3109 id: 1usize,
3110 }
3111 .build(),
3112 aggregate::info::variant::Builder {
3113 name: aggregate::info::Str::new("ECN\0"),
3114 id: 2usize,
3115 }
3116 .build(),
3117 aggregate::info::variant::Builder {
3118 name: aggregate::info::Str::new("BASE_MTU\0"),
3119 id: 3usize,
3120 }
3121 .build(),
3122 aggregate::info::variant::Builder {
3123 name: aggregate::info::Str::new("INITIAL_MTU\0"),
3124 id: 4usize,
3125 }
3126 .build(),
3127 aggregate::info::variant::Builder {
3128 name: aggregate::info::Str::new("MAX_MTU\0"),
3129 id: 5usize,
3130 }
3131 .build(),
3132 ];
3133 #[inline]
3134 fn variant_idx(&self) -> usize {
3135 match self {
3136 Self::Gso { .. } => 0usize,
3137 Self::Gro { .. } => 1usize,
3138 Self::Ecn { .. } => 2usize,
3139 Self::BaseMtu { .. } => 3usize,
3140 Self::InitialMtu { .. } => 4usize,
3141 Self::MaxMtu { .. } => 5usize,
3142 }
3143 }
3144 }
3145 impl<'a> IntoEvent<builder::PreferredAddress<'a>>
3146 for &'a crate::transport::parameters::PreferredAddress
3147 {
3148 #[inline]
3149 fn into_event(self) -> builder::PreferredAddress<'a> {
3150 builder::PreferredAddress {
3151 ipv4_address: self.ipv4_address.as_ref().map(|addr| addr.into_event()),
3152 ipv6_address: self.ipv6_address.as_ref().map(|addr| addr.into_event()),
3153 connection_id: self.connection_id.into_event(),
3154 stateless_reset_token: self.stateless_reset_token.as_ref(),
3155 }
3156 }
3157 }
3158 impl<'a> IntoEvent<builder::SocketAddress<'a>> for &'a crate::inet::ipv4::SocketAddressV4 {
3159 #[inline]
3160 fn into_event(self) -> builder::SocketAddress<'a> {
3161 builder::SocketAddress::IpV4 {
3162 ip: &self.ip.octets,
3163 port: self.port.into(),
3164 }
3165 }
3166 }
3167 impl<'a> IntoEvent<builder::SocketAddress<'a>> for &'a crate::inet::ipv6::SocketAddressV6 {
3168 #[inline]
3169 fn into_event(self) -> builder::SocketAddress<'a> {
3170 builder::SocketAddress::IpV6 {
3171 ip: &self.ip.octets,
3172 port: self.port.into(),
3173 }
3174 }
3175 }
3176 impl IntoEvent<bool> for &crate::transport::parameters::MigrationSupport {
3177 #[inline]
3178 fn into_event(self) -> bool {
3179 match self {
3180 crate::transport::parameters::MigrationSupport::Enabled => true,
3181 crate::transport::parameters::MigrationSupport::Disabled => false,
3182 }
3183 }
3184 }
3185 impl<'a> core::fmt::Debug for ConnectionId<'a> {
3186 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
3187 write!(f, "0x")?;
3188 for byte in self.bytes {
3189 write!(f, "{byte:02x}")?;
3190 }
3191 Ok(())
3192 }
3193 }
3194 macro_rules! impl_conn_id {
3195 ($name:ident) => {
3196 impl<'a> IntoEvent<builder::ConnectionId<'a>> for &'a crate::connection::id::$name {
3197 #[inline]
3198 fn into_event(self) -> builder::ConnectionId<'a> {
3199 builder::ConnectionId {
3200 bytes: self.as_bytes(),
3201 }
3202 }
3203 }
3204 };
3205 }
3206 impl_conn_id!(LocalId);
3207 impl_conn_id!(PeerId);
3208 impl_conn_id!(UnboundedId);
3209 impl_conn_id!(InitialId);
3210 impl<'a> core::fmt::Debug for SocketAddress<'a> {
3211 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
3212 match self {
3213 Self::IpV4 { ip, port } => {
3214 let addr = crate::inet::SocketAddressV4::new(**ip, *port);
3215 write!(f, "{addr}")?;
3216 }
3217 Self::IpV6 { ip, port } => {
3218 let addr = crate::inet::SocketAddressV6::new(**ip, *port);
3219 write!(f, "{addr}")?;
3220 }
3221 }
3222 Ok(())
3223 }
3224 }
3225 impl<'a> core::fmt::Display for SocketAddress<'a> {
3226 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
3227 match self {
3228 Self::IpV4 { ip, port } => {
3229 let addr = crate::inet::SocketAddressV4::new(**ip, *port);
3230 addr.fmt(f)?;
3231 }
3232 Self::IpV6 { ip, port } => {
3233 let addr = crate::inet::SocketAddressV6::new(**ip, *port);
3234 addr.fmt(f)?;
3235 }
3236 }
3237 Ok(())
3238 }
3239 }
3240 impl<'a> SocketAddress<'a> {
3241 #[inline]
3242 pub fn ip(&self) -> &'a [u8] {
3243 match self {
3244 Self::IpV4 { ip, .. } => &ip[..],
3245 Self::IpV6 { ip, .. } => &ip[..],
3246 }
3247 }
3248 #[inline]
3249 pub fn port(&self) -> u16 {
3250 match self {
3251 Self::IpV4 { port, .. } => *port,
3252 Self::IpV6 { port, .. } => *port,
3253 }
3254 }
3255 }
3256 impl<'a> IntoEvent<api::SocketAddress<'a>> for &'a crate::inet::SocketAddress {
3257 #[inline]
3258 fn into_event(self) -> api::SocketAddress<'a> {
3259 match self {
3260 crate::inet::SocketAddress::IpV4(addr) => api::SocketAddress::IpV4 {
3261 ip: &addr.ip.octets,
3262 port: addr.port.into(),
3263 },
3264 crate::inet::SocketAddress::IpV6(addr) => api::SocketAddress::IpV6 {
3265 ip: &addr.ip.octets,
3266 port: addr.port.into(),
3267 },
3268 }
3269 }
3270 }
3271 impl<'a> IntoEvent<builder::SocketAddress<'a>> for &'a crate::inet::SocketAddress {
3272 #[inline]
3273 fn into_event(self) -> builder::SocketAddress<'a> {
3274 match self {
3275 crate::inet::SocketAddress::IpV4(addr) => addr.into_event(),
3276 crate::inet::SocketAddress::IpV6(addr) => addr.into_event(),
3277 }
3278 }
3279 }
3280 #[cfg(feature = "std")]
3281 impl From<SocketAddress<'_>> for std::net::SocketAddr {
3282 #[inline]
3283 fn from(address: SocketAddress) -> Self {
3284 use std::net;
3285 match address {
3286 SocketAddress::IpV4 { ip, port } => {
3287 let ip = net::IpAddr::V4(net::Ipv4Addr::from(*ip));
3288 Self::new(ip, port)
3289 }
3290 SocketAddress::IpV6 { ip, port } => {
3291 let ip = net::IpAddr::V6(net::Ipv6Addr::from(*ip));
3292 Self::new(ip, port)
3293 }
3294 }
3295 }
3296 }
3297 #[cfg(feature = "std")]
3298 impl From<&SocketAddress<'_>> for std::net::SocketAddr {
3299 #[inline]
3300 fn from(address: &SocketAddress) -> Self {
3301 use std::net;
3302 match address {
3303 SocketAddress::IpV4 { ip, port } => {
3304 let ip = net::IpAddr::V4(net::Ipv4Addr::from(**ip));
3305 Self::new(ip, *port)
3306 }
3307 SocketAddress::IpV6 { ip, port } => {
3308 let ip = net::IpAddr::V6(net::Ipv6Addr::from(**ip));
3309 Self::new(ip, *port)
3310 }
3311 }
3312 }
3313 }
3314 impl IntoEvent<builder::DuplicatePacketError> for crate::packet::number::SlidingWindowError {
3315 #[inline]
3316 fn into_event(self) -> builder::DuplicatePacketError {
3317 use crate::packet::number::SlidingWindowError;
3318 match self {
3319 SlidingWindowError::TooOld => builder::DuplicatePacketError::TooOld {},
3320 SlidingWindowError::Duplicate => builder::DuplicatePacketError::Duplicate {},
3321 }
3322 }
3323 }
3324 impl IntoEvent<builder::EcnCounts> for crate::frame::ack::EcnCounts {
3325 #[inline]
3326 fn into_event(self) -> builder::EcnCounts {
3327 builder::EcnCounts {
3328 ect_0_count: self.ect_0_count.into_event(),
3329 ect_1_count: self.ect_1_count.into_event(),
3330 ce_count: self.ce_count.into_event(),
3331 }
3332 }
3333 }
3334 impl IntoEvent<builder::Frame> for &crate::frame::Padding {
3335 #[inline]
3336 fn into_event(self) -> builder::Frame {
3337 builder::Frame::Padding {}
3338 }
3339 }
3340 impl IntoEvent<builder::Frame> for &crate::frame::Ping {
3341 #[inline]
3342 fn into_event(self) -> builder::Frame {
3343 builder::Frame::Ping {}
3344 }
3345 }
3346 impl<AckRanges: crate::frame::ack::AckRanges> IntoEvent<builder::Frame>
3347 for &crate::frame::Ack<AckRanges>
3348 {
3349 #[inline]
3350 fn into_event(self) -> builder::Frame {
3351 builder::Frame::Ack {
3352 ecn_counts: self.ecn_counts.map(|val| val.into_event()),
3353 largest_acknowledged: self.largest_acknowledged().into_event(),
3354 ack_range_count: self.ack_ranges().len() as u64,
3355 }
3356 }
3357 }
3358 impl IntoEvent<builder::Frame> for &crate::frame::ResetStream {
3359 #[inline]
3360 fn into_event(self) -> builder::Frame {
3361 builder::Frame::ResetStream {
3362 id: self.stream_id.as_u64(),
3363 error_code: self.application_error_code.as_u64(),
3364 final_size: self.final_size.as_u64(),
3365 }
3366 }
3367 }
3368 impl IntoEvent<builder::Frame> for &crate::frame::StopSending {
3369 #[inline]
3370 fn into_event(self) -> builder::Frame {
3371 builder::Frame::StopSending {
3372 id: self.stream_id.as_u64(),
3373 error_code: self.application_error_code.as_u64(),
3374 }
3375 }
3376 }
3377 impl<'a> IntoEvent<builder::Frame> for &crate::frame::NewToken<'a> {
3378 #[inline]
3379 fn into_event(self) -> builder::Frame {
3380 builder::Frame::NewToken {}
3381 }
3382 }
3383 impl IntoEvent<builder::Frame> for &crate::frame::MaxData {
3384 #[inline]
3385 fn into_event(self) -> builder::Frame {
3386 builder::Frame::MaxData {
3387 value: self.maximum_data.as_u64(),
3388 }
3389 }
3390 }
3391 impl IntoEvent<builder::Frame> for &crate::frame::MaxStreamData {
3392 #[inline]
3393 fn into_event(self) -> builder::Frame {
3394 builder::Frame::MaxStreamData {
3395 id: self.stream_id.as_u64(),
3396 stream_type: crate::stream::StreamId::from_varint(self.stream_id)
3397 .stream_type()
3398 .into_event(),
3399 value: self.maximum_stream_data.as_u64(),
3400 }
3401 }
3402 }
3403 impl IntoEvent<builder::Frame> for &crate::frame::MaxStreams {
3404 #[inline]
3405 fn into_event(self) -> builder::Frame {
3406 builder::Frame::MaxStreams {
3407 stream_type: self.stream_type.into_event(),
3408 value: self.maximum_streams.as_u64(),
3409 }
3410 }
3411 }
3412 impl IntoEvent<builder::Frame> for &crate::frame::DataBlocked {
3413 #[inline]
3414 fn into_event(self) -> builder::Frame {
3415 builder::Frame::DataBlocked {
3416 data_limit: self.data_limit.as_u64(),
3417 }
3418 }
3419 }
3420 impl IntoEvent<builder::Frame> for &crate::frame::StreamDataBlocked {
3421 #[inline]
3422 fn into_event(self) -> builder::Frame {
3423 builder::Frame::StreamDataBlocked {
3424 stream_id: self.stream_id.as_u64(),
3425 stream_data_limit: self.stream_data_limit.as_u64(),
3426 }
3427 }
3428 }
3429 impl IntoEvent<builder::Frame> for &crate::frame::StreamsBlocked {
3430 #[inline]
3431 fn into_event(self) -> builder::Frame {
3432 builder::Frame::StreamsBlocked {
3433 stream_type: self.stream_type.into_event(),
3434 stream_limit: self.stream_limit.as_u64(),
3435 }
3436 }
3437 }
3438 impl<'a> IntoEvent<builder::Frame> for &crate::frame::NewConnectionId<'a> {
3439 #[inline]
3440 fn into_event(self) -> builder::Frame {
3441 builder::Frame::NewConnectionId {
3442 sequence_number: self.sequence_number.as_u64(),
3443 retire_prior_to: self.retire_prior_to.as_u64(),
3444 }
3445 }
3446 }
3447 impl IntoEvent<builder::Frame> for &crate::frame::RetireConnectionId {
3448 #[inline]
3449 fn into_event(self) -> builder::Frame {
3450 builder::Frame::RetireConnectionId {}
3451 }
3452 }
3453 impl<'a> IntoEvent<builder::Frame> for &crate::frame::PathChallenge<'a> {
3454 #[inline]
3455 fn into_event(self) -> builder::Frame {
3456 builder::Frame::PathChallenge {}
3457 }
3458 }
3459 impl<'a> IntoEvent<builder::Frame> for &crate::frame::PathResponse<'a> {
3460 #[inline]
3461 fn into_event(self) -> builder::Frame {
3462 builder::Frame::PathResponse {}
3463 }
3464 }
3465 impl<'a> IntoEvent<builder::Frame> for &crate::frame::ConnectionClose<'a> {
3466 #[inline]
3467 fn into_event(self) -> builder::Frame {
3468 builder::Frame::ConnectionClose {}
3469 }
3470 }
3471 impl IntoEvent<builder::Frame> for &crate::frame::HandshakeDone {
3472 #[inline]
3473 fn into_event(self) -> builder::Frame {
3474 builder::Frame::HandshakeDone {}
3475 }
3476 }
3477 impl<Data> IntoEvent<builder::Frame> for &crate::frame::Stream<Data>
3478 where
3479 Data: s2n_codec::EncoderValue,
3480 {
3481 #[inline]
3482 fn into_event(self) -> builder::Frame {
3483 builder::Frame::Stream {
3484 id: self.stream_id.as_u64(),
3485 offset: self.offset.as_u64(),
3486 len: self.data.encoding_size() as _,
3487 is_fin: self.is_fin,
3488 }
3489 }
3490 }
3491 impl<Data> IntoEvent<builder::Frame> for &crate::frame::Crypto<Data>
3492 where
3493 Data: s2n_codec::EncoderValue,
3494 {
3495 #[inline]
3496 fn into_event(self) -> builder::Frame {
3497 builder::Frame::Crypto {
3498 offset: self.offset.as_u64(),
3499 len: self.data.encoding_size() as _,
3500 }
3501 }
3502 }
3503 impl<Data> IntoEvent<builder::Frame> for &crate::frame::Datagram<Data>
3504 where
3505 Data: s2n_codec::EncoderValue,
3506 {
3507 #[inline]
3508 fn into_event(self) -> builder::Frame {
3509 builder::Frame::Datagram {
3510 len: self.data.encoding_size() as _,
3511 }
3512 }
3513 }
3514 impl<'a> IntoEvent<builder::Frame> for &crate::frame::DcStatelessResetTokens<'a> {
3515 #[inline]
3516 fn into_event(self) -> builder::Frame {
3517 builder::Frame::DcStatelessResetTokens {}
3518 }
3519 }
3520 #[cfg(feature = "alloc")]
3521 impl<'a> ConnectionCloseFrame<'a> {
3522 #[doc = " Converts the reason to a UTF-8 `str`, including invalid characters"]
3523 pub fn reason_lossy_utf8(&self) -> Option<alloc::borrow::Cow<'a, str>> {
3524 self.reason
3525 .map(|reason| alloc::string::String::from_utf8_lossy(reason))
3526 }
3527 }
3528 impl<'a> IntoEvent<builder::ConnectionCloseFrame<'a>> for &crate::frame::ConnectionClose<'a> {
3529 #[inline]
3530 fn into_event(self) -> builder::ConnectionCloseFrame<'a> {
3531 builder::ConnectionCloseFrame {
3532 error_code: self.error_code.as_u64(),
3533 frame_type: self.frame_type.into_event(),
3534 reason: self.reason.into_event(),
3535 }
3536 }
3537 }
3538 #[cfg(feature = "alloc")]
3539 impl<'a> core::fmt::Debug for ConnectionCloseFrame<'a> {
3540 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
3541 f.debug_struct("ConnectionCloseFrame")
3542 .field("error_code", &self.error_code)
3543 .field("frame_type", &self.frame_type)
3544 .field("reason", &self.reason_lossy_utf8())
3545 .finish()
3546 }
3547 }
3548 #[cfg(not(feature = "alloc"))]
3549 impl<'a> core::fmt::Debug for ConnectionCloseFrame<'a> {
3550 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
3551 write!(f, "{:?}", self)
3552 }
3553 }
3554 impl IntoEvent<builder::StreamType> for &crate::stream::StreamType {
3555 #[inline]
3556 fn into_event(self) -> builder::StreamType {
3557 match self {
3558 crate::stream::StreamType::Bidirectional => builder::StreamType::Bidirectional {},
3559 crate::stream::StreamType::Unidirectional => builder::StreamType::Unidirectional {},
3560 }
3561 }
3562 }
3563 impl builder::PacketHeader {
3564 #[inline]
3565 pub fn new(
3566 packet_number: crate::packet::number::PacketNumber,
3567 version: u32,
3568 ) -> builder::PacketHeader {
3569 use crate::packet::number::PacketNumberSpace;
3570 use builder::PacketHeader;
3571 match packet_number.space() {
3572 PacketNumberSpace::Initial => PacketHeader::Initial {
3573 number: packet_number.into_event(),
3574 version,
3575 },
3576 PacketNumberSpace::Handshake => PacketHeader::Handshake {
3577 number: packet_number.into_event(),
3578 version,
3579 },
3580 PacketNumberSpace::ApplicationData => PacketHeader::OneRtt {
3581 number: packet_number.into_event(),
3582 },
3583 }
3584 }
3585 }
3586 impl core::fmt::Display for EndpointType {
3587 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
3588 match self {
3589 Self::Client {} => write!(f, "client"),
3590 Self::Server {} => write!(f, "server"),
3591 }
3592 }
3593 }
3594 impl IntoEvent<api::EndpointType> for crate::endpoint::Type {
3595 #[inline]
3596 fn into_event(self) -> api::EndpointType {
3597 match self {
3598 Self::Client => api::EndpointType::Client {},
3599 Self::Server => api::EndpointType::Server {},
3600 }
3601 }
3602 }
3603 impl IntoEvent<builder::EndpointType> for crate::endpoint::Type {
3604 #[inline]
3605 fn into_event(self) -> builder::EndpointType {
3606 match self {
3607 Self::Client => builder::EndpointType::Client {},
3608 Self::Server => builder::EndpointType::Server {},
3609 }
3610 }
3611 }
3612 impl<'a> IntoEvent<builder::MtuConfig> for &'a crate::path::mtu::Config {
3613 #[inline]
3614 fn into_event(self) -> builder::MtuConfig {
3615 builder::MtuConfig {
3616 initial_mtu: self.initial_mtu().into(),
3617 base_mtu: self.base_mtu().into(),
3618 max_mtu: self.max_mtu().into(),
3619 }
3620 }
3621 }
3622 impl CipherSuite {
3623 #[inline]
3624 pub fn as_str(&self) -> &'static str {
3625 match self {
3626 Self::TLS_AES_128_GCM_SHA256 {} => "TLS_AES_128_GCM_SHA256",
3627 Self::TLS_AES_256_GCM_SHA384 {} => "TLS_AES_256_GCM_SHA384",
3628 Self::TLS_CHACHA20_POLY1305_SHA256 {} => "TLS_CHACHA20_POLY1305_SHA256",
3629 Self::Unknown {} => "UNKNOWN",
3630 }
3631 }
3632 }
3633 #[cfg(feature = "std")]
3634 impl From<PlatformTxError> for std::io::Error {
3635 fn from(error: PlatformTxError) -> Self {
3636 Self::from_raw_os_error(error.errno)
3637 }
3638 }
3639 #[cfg(feature = "std")]
3640 impl From<PlatformRxError> for std::io::Error {
3641 fn from(error: PlatformRxError) -> Self {
3642 Self::from_raw_os_error(error.errno)
3643 }
3644 }
3645}
3646#[cfg(feature = "event-tracing")]
3647pub mod tracing {
3648 #"]
3649 use super::api;
3650 #[doc = r" Emits events with [`tracing`](https://docs.rs/tracing)"]
3651 #[derive(Clone, Debug)]
3652 pub struct Subscriber {
3653 client: tracing::Span,
3654 server: tracing::Span,
3655 }
3656 impl Default for Subscriber {
3657 fn default() -> Self {
3658 let root =
3659 tracing :: span ! (target : "s2n_quic" , tracing :: Level :: DEBUG , "s2n_quic");
3660 let client =
3661 tracing :: span ! (parent : root . id () , tracing :: Level :: DEBUG , "client");
3662 let server =
3663 tracing :: span ! (parent : root . id () , tracing :: Level :: DEBUG , "server");
3664 Self { client, server }
3665 }
3666 }
3667 impl Subscriber {
3668 fn parent<M: crate::event::Meta>(&self, meta: &M) -> Option<tracing::Id> {
3669 match meta.endpoint_type() {
3670 api::EndpointType::Client { .. } => self.client.id(),
3671 api::EndpointType::Server { .. } => self.server.id(),
3672 }
3673 }
3674 }
3675 impl super::Subscriber for Subscriber {
3676 type ConnectionContext = tracing::Span;
3677 fn create_connection_context(
3678 &mut self,
3679 meta: &api::ConnectionMeta,
3680 _info: &api::ConnectionInfo,
3681 ) -> Self::ConnectionContext {
3682 let parent = self.parent(meta);
3683 tracing :: span ! (target : "s2n_quic" , parent : parent , tracing :: Level :: DEBUG , "conn" , id = meta . id)
3684 }
3685 #[inline]
3686 fn on_application_protocol_information(
3687 &mut self,
3688 context: &mut Self::ConnectionContext,
3689 _meta: &api::ConnectionMeta,
3690 event: &api::ApplicationProtocolInformation,
3691 ) {
3692 let id = context.id();
3693 let api::ApplicationProtocolInformation {
3694 chosen_application_protocol,
3695 } = event;
3696 tracing :: event ! (target : "application_protocol_information" , parent : id , tracing :: Level :: DEBUG , { chosen_application_protocol = tracing :: field :: debug (chosen_application_protocol) });
3697 }
3698 #[inline]
3699 fn on_server_name_information(
3700 &mut self,
3701 context: &mut Self::ConnectionContext,
3702 _meta: &api::ConnectionMeta,
3703 event: &api::ServerNameInformation,
3704 ) {
3705 let id = context.id();
3706 let api::ServerNameInformation { chosen_server_name } = event;
3707 tracing :: event ! (target : "server_name_information" , parent : id , tracing :: Level :: DEBUG , { chosen_server_name = tracing :: field :: debug (chosen_server_name) });
3708 }
3709 #[inline]
3710 fn on_key_exchange_group(
3711 &mut self,
3712 context: &mut Self::ConnectionContext,
3713 _meta: &api::ConnectionMeta,
3714 event: &api::KeyExchangeGroup,
3715 ) {
3716 let id = context.id();
3717 let api::KeyExchangeGroup {
3718 chosen_group_name,
3719 contains_kem,
3720 } = event;
3721 tracing :: event ! (target : "key_exchange_group" , parent : id , tracing :: Level :: DEBUG , { chosen_group_name = tracing :: field :: debug (chosen_group_name) , contains_kem = tracing :: field :: debug (contains_kem) });
3722 }
3723 #[inline]
3724 fn on_packet_skipped(
3725 &mut self,
3726 context: &mut Self::ConnectionContext,
3727 _meta: &api::ConnectionMeta,
3728 event: &api::PacketSkipped,
3729 ) {
3730 let id = context.id();
3731 let api::PacketSkipped {
3732 number,
3733 space,
3734 reason,
3735 } = event;
3736 tracing :: event ! (target : "packet_skipped" , parent : id , tracing :: Level :: DEBUG , { number = tracing :: field :: debug (number) , space = tracing :: field :: debug (space) , reason = tracing :: field :: debug (reason) });
3737 }
3738 #[inline]
3739 fn on_packet_sent(
3740 &mut self,
3741 context: &mut Self::ConnectionContext,
3742 _meta: &api::ConnectionMeta,
3743 event: &api::PacketSent,
3744 ) {
3745 let id = context.id();
3746 let api::PacketSent {
3747 packet_header,
3748 packet_len,
3749 } = event;
3750 tracing :: event ! (target : "packet_sent" , parent : id , tracing :: Level :: DEBUG , { packet_header = tracing :: field :: debug (packet_header) , packet_len = tracing :: field :: debug (packet_len) });
3751 }
3752 #[inline]
3753 fn on_packet_received(
3754 &mut self,
3755 context: &mut Self::ConnectionContext,
3756 _meta: &api::ConnectionMeta,
3757 event: &api::PacketReceived,
3758 ) {
3759 let id = context.id();
3760 let api::PacketReceived { packet_header } = event;
3761 tracing :: event ! (target : "packet_received" , parent : id , tracing :: Level :: DEBUG , { packet_header = tracing :: field :: debug (packet_header) });
3762 }
3763 #[inline]
3764 fn on_active_path_updated(
3765 &mut self,
3766 context: &mut Self::ConnectionContext,
3767 _meta: &api::ConnectionMeta,
3768 event: &api::ActivePathUpdated,
3769 ) {
3770 let id = context.id();
3771 let api::ActivePathUpdated { previous, active } = event;
3772 tracing :: event ! (target : "active_path_updated" , parent : id , tracing :: Level :: DEBUG , { previous = tracing :: field :: debug (previous) , active = tracing :: field :: debug (active) });
3773 }
3774 #[inline]
3775 fn on_path_created(
3776 &mut self,
3777 context: &mut Self::ConnectionContext,
3778 _meta: &api::ConnectionMeta,
3779 event: &api::PathCreated,
3780 ) {
3781 let id = context.id();
3782 let api::PathCreated { active, new } = event;
3783 tracing :: event ! (target : "path_created" , parent : id , tracing :: Level :: DEBUG , { active = tracing :: field :: debug (active) , new = tracing :: field :: debug (new) });
3784 }
3785 #[inline]
3786 fn on_frame_sent(
3787 &mut self,
3788 context: &mut Self::ConnectionContext,
3789 _meta: &api::ConnectionMeta,
3790 event: &api::FrameSent,
3791 ) {
3792 let id = context.id();
3793 let api::FrameSent {
3794 packet_header,
3795 path_id,
3796 frame,
3797 } = event;
3798 tracing :: event ! (target : "frame_sent" , parent : id , tracing :: Level :: DEBUG , { packet_header = tracing :: field :: debug (packet_header) , path_id = tracing :: field :: debug (path_id) , frame = tracing :: field :: debug (frame) });
3799 }
3800 #[inline]
3801 fn on_frame_received(
3802 &mut self,
3803 context: &mut Self::ConnectionContext,
3804 _meta: &api::ConnectionMeta,
3805 event: &api::FrameReceived,
3806 ) {
3807 let id = context.id();
3808 let api::FrameReceived {
3809 packet_header,
3810 path,
3811 frame,
3812 } = event;
3813 tracing :: event ! (target : "frame_received" , parent : id , tracing :: Level :: DEBUG , { packet_header = tracing :: field :: debug (packet_header) , path = tracing :: field :: debug (path) , frame = tracing :: field :: debug (frame) });
3814 }
3815 #[inline]
3816 fn on_connection_close_frame_received(
3817 &mut self,
3818 context: &mut Self::ConnectionContext,
3819 _meta: &api::ConnectionMeta,
3820 event: &api::ConnectionCloseFrameReceived,
3821 ) {
3822 let id = context.id();
3823 let api::ConnectionCloseFrameReceived {
3824 packet_header,
3825 path,
3826 frame,
3827 } = event;
3828 tracing :: event ! (target : "connection_close_frame_received" , parent : id , tracing :: Level :: DEBUG , { packet_header = tracing :: field :: debug (packet_header) , path = tracing :: field :: debug (path) , frame = tracing :: field :: debug (frame) });
3829 }
3830 #[inline]
3831 fn on_packet_lost(
3832 &mut self,
3833 context: &mut Self::ConnectionContext,
3834 _meta: &api::ConnectionMeta,
3835 event: &api::PacketLost,
3836 ) {
3837 let id = context.id();
3838 let api::PacketLost {
3839 packet_header,
3840 path,
3841 bytes_lost,
3842 is_mtu_probe,
3843 } = event;
3844 tracing :: event ! (target : "packet_lost" , parent : id , tracing :: Level :: DEBUG , { packet_header = tracing :: field :: debug (packet_header) , path = tracing :: field :: debug (path) , bytes_lost = tracing :: field :: debug (bytes_lost) , is_mtu_probe = tracing :: field :: debug (is_mtu_probe) });
3845 }
3846 #[inline]
3847 fn on_recovery_metrics(
3848 &mut self,
3849 context: &mut Self::ConnectionContext,
3850 _meta: &api::ConnectionMeta,
3851 event: &api::RecoveryMetrics,
3852 ) {
3853 let id = context.id();
3854 let api::RecoveryMetrics {
3855 path,
3856 min_rtt,
3857 smoothed_rtt,
3858 latest_rtt,
3859 rtt_variance,
3860 max_ack_delay,
3861 pto_count,
3862 congestion_window,
3863 bytes_in_flight,
3864 congestion_limited,
3865 } = event;
3866 tracing :: event ! (target : "recovery_metrics" , parent : id , tracing :: Level :: DEBUG , { path = tracing :: field :: debug (path) , min_rtt = tracing :: field :: debug (min_rtt) , smoothed_rtt = tracing :: field :: debug (smoothed_rtt) , latest_rtt = tracing :: field :: debug (latest_rtt) , rtt_variance = tracing :: field :: debug (rtt_variance) , max_ack_delay = tracing :: field :: debug (max_ack_delay) , pto_count = tracing :: field :: debug (pto_count) , congestion_window = tracing :: field :: debug (congestion_window) , bytes_in_flight = tracing :: field :: debug (bytes_in_flight) , congestion_limited = tracing :: field :: debug (congestion_limited) });
3867 }
3868 #[inline]
3869 fn on_congestion(
3870 &mut self,
3871 context: &mut Self::ConnectionContext,
3872 _meta: &api::ConnectionMeta,
3873 event: &api::Congestion,
3874 ) {
3875 let id = context.id();
3876 let api::Congestion { path, source } = event;
3877 tracing :: event ! (target : "congestion" , parent : id , tracing :: Level :: DEBUG , { path = tracing :: field :: debug (path) , source = tracing :: field :: debug (source) });
3878 }
3879 #[inline]
3880 #[allow(deprecated)]
3881 fn on_ack_processed(
3882 &mut self,
3883 context: &mut Self::ConnectionContext,
3884 _meta: &api::ConnectionMeta,
3885 event: &api::AckProcessed,
3886 ) {
3887 let id = context.id();
3888 let api::AckProcessed { action, path } = event;
3889 tracing :: event ! (target : "ack_processed" , parent : id , tracing :: Level :: DEBUG , { action = tracing :: field :: debug (action) , path = tracing :: field :: debug (path) });
3890 }
3891 #[inline]
3892 fn on_rx_ack_range_dropped(
3893 &mut self,
3894 context: &mut Self::ConnectionContext,
3895 _meta: &api::ConnectionMeta,
3896 event: &api::RxAckRangeDropped,
3897 ) {
3898 let id = context.id();
3899 let api::RxAckRangeDropped {
3900 path,
3901 packet_number_range,
3902 capacity,
3903 stored_range,
3904 } = event;
3905 tracing :: event ! (target : "rx_ack_range_dropped" , parent : id , tracing :: Level :: DEBUG , { path = tracing :: field :: debug (path) , packet_number_range = tracing :: field :: debug (packet_number_range) , capacity = tracing :: field :: debug (capacity) , stored_range = tracing :: field :: debug (stored_range) });
3906 }
3907 #[inline]
3908 fn on_ack_range_received(
3909 &mut self,
3910 context: &mut Self::ConnectionContext,
3911 _meta: &api::ConnectionMeta,
3912 event: &api::AckRangeReceived,
3913 ) {
3914 let id = context.id();
3915 let api::AckRangeReceived {
3916 packet_header,
3917 path,
3918 ack_range,
3919 } = event;
3920 tracing :: event ! (target : "ack_range_received" , parent : id , tracing :: Level :: DEBUG , { packet_header = tracing :: field :: debug (packet_header) , path = tracing :: field :: debug (path) , ack_range = tracing :: field :: debug (ack_range) });
3921 }
3922 #[inline]
3923 fn on_ack_range_sent(
3924 &mut self,
3925 context: &mut Self::ConnectionContext,
3926 _meta: &api::ConnectionMeta,
3927 event: &api::AckRangeSent,
3928 ) {
3929 let id = context.id();
3930 let api::AckRangeSent {
3931 packet_header,
3932 path_id,
3933 ack_range,
3934 } = event;
3935 tracing :: event ! (target : "ack_range_sent" , parent : id , tracing :: Level :: DEBUG , { packet_header = tracing :: field :: debug (packet_header) , path_id = tracing :: field :: debug (path_id) , ack_range = tracing :: field :: debug (ack_range) });
3936 }
3937 #[inline]
3938 fn on_packet_dropped(
3939 &mut self,
3940 context: &mut Self::ConnectionContext,
3941 _meta: &api::ConnectionMeta,
3942 event: &api::PacketDropped,
3943 ) {
3944 let id = context.id();
3945 let api::PacketDropped { reason } = event;
3946 tracing :: event ! (target : "packet_dropped" , parent : id , tracing :: Level :: DEBUG , { reason = tracing :: field :: debug (reason) });
3947 }
3948 #[inline]
3949 fn on_key_update(
3950 &mut self,
3951 context: &mut Self::ConnectionContext,
3952 _meta: &api::ConnectionMeta,
3953 event: &api::KeyUpdate,
3954 ) {
3955 let id = context.id();
3956 let api::KeyUpdate {
3957 key_type,
3958 cipher_suite,
3959 } = event;
3960 tracing :: event ! (target : "key_update" , parent : id , tracing :: Level :: DEBUG , { key_type = tracing :: field :: debug (key_type) , cipher_suite = tracing :: field :: debug (cipher_suite) });
3961 }
3962 #[inline]
3963 fn on_key_space_discarded(
3964 &mut self,
3965 context: &mut Self::ConnectionContext,
3966 _meta: &api::ConnectionMeta,
3967 event: &api::KeySpaceDiscarded,
3968 ) {
3969 let id = context.id();
3970 let api::KeySpaceDiscarded { space } = event;
3971 tracing :: event ! (target : "key_space_discarded" , parent : id , tracing :: Level :: DEBUG , { space = tracing :: field :: debug (space) });
3972 }
3973 #[inline]
3974 fn on_connection_started(
3975 &mut self,
3976 context: &mut Self::ConnectionContext,
3977 _meta: &api::ConnectionMeta,
3978 event: &api::ConnectionStarted,
3979 ) {
3980 let id = context.id();
3981 let api::ConnectionStarted { path } = event;
3982 tracing :: event ! (target : "connection_started" , parent : id , tracing :: Level :: DEBUG , { path = tracing :: field :: debug (path) });
3983 }
3984 #[inline]
3985 fn on_duplicate_packet(
3986 &mut self,
3987 context: &mut Self::ConnectionContext,
3988 _meta: &api::ConnectionMeta,
3989 event: &api::DuplicatePacket,
3990 ) {
3991 let id = context.id();
3992 let api::DuplicatePacket {
3993 packet_header,
3994 path,
3995 error,
3996 } = event;
3997 tracing :: event ! (target : "duplicate_packet" , parent : id , tracing :: Level :: DEBUG , { packet_header = tracing :: field :: debug (packet_header) , path = tracing :: field :: debug (path) , error = tracing :: field :: debug (error) });
3998 }
3999 #[inline]
4000 fn on_transport_parameters_received(
4001 &mut self,
4002 context: &mut Self::ConnectionContext,
4003 _meta: &api::ConnectionMeta,
4004 event: &api::TransportParametersReceived,
4005 ) {
4006 let id = context.id();
4007 let api::TransportParametersReceived {
4008 transport_parameters,
4009 } = event;
4010 tracing :: event ! (target : "transport_parameters_received" , parent : id , tracing :: Level :: DEBUG , { transport_parameters = tracing :: field :: debug (transport_parameters) });
4011 }
4012 #[inline]
4013 fn on_datagram_sent(
4014 &mut self,
4015 context: &mut Self::ConnectionContext,
4016 _meta: &api::ConnectionMeta,
4017 event: &api::DatagramSent,
4018 ) {
4019 let id = context.id();
4020 let api::DatagramSent { len, gso_offset } = event;
4021 tracing :: event ! (target : "datagram_sent" , parent : id , tracing :: Level :: DEBUG , { len = tracing :: field :: debug (len) , gso_offset = tracing :: field :: debug (gso_offset) });
4022 }
4023 #[inline]
4024 fn on_datagram_received(
4025 &mut self,
4026 context: &mut Self::ConnectionContext,
4027 _meta: &api::ConnectionMeta,
4028 event: &api::DatagramReceived,
4029 ) {
4030 let id = context.id();
4031 let api::DatagramReceived { len } = event;
4032 tracing :: event ! (target : "datagram_received" , parent : id , tracing :: Level :: DEBUG , { len = tracing :: field :: debug (len) });
4033 }
4034 #[inline]
4035 fn on_datagram_dropped(
4036 &mut self,
4037 context: &mut Self::ConnectionContext,
4038 _meta: &api::ConnectionMeta,
4039 event: &api::DatagramDropped,
4040 ) {
4041 let id = context.id();
4042 let api::DatagramDropped {
4043 local_addr,
4044 remote_addr,
4045 destination_cid,
4046 source_cid,
4047 len,
4048 reason,
4049 } = event;
4050 tracing :: event ! (target : "datagram_dropped" , parent : id , tracing :: Level :: DEBUG , { local_addr = tracing :: field :: debug (local_addr) , remote_addr = tracing :: field :: debug (remote_addr) , destination_cid = tracing :: field :: debug (destination_cid) , source_cid = tracing :: field :: debug (source_cid) , len = tracing :: field :: debug (len) , reason = tracing :: field :: debug (reason) });
4051 }
4052 #[inline]
4053 fn on_handshake_remote_address_change_observed(
4054 &mut self,
4055 context: &mut Self::ConnectionContext,
4056 _meta: &api::ConnectionMeta,
4057 event: &api::HandshakeRemoteAddressChangeObserved,
4058 ) {
4059 let id = context.id();
4060 let api::HandshakeRemoteAddressChangeObserved {
4061 local_addr,
4062 remote_addr,
4063 initial_remote_addr,
4064 } = event;
4065 tracing :: event ! (target : "handshake_remote_address_change_observed" , parent : id , tracing :: Level :: DEBUG , { local_addr = tracing :: field :: debug (local_addr) , remote_addr = tracing :: field :: debug (remote_addr) , initial_remote_addr = tracing :: field :: debug (initial_remote_addr) });
4066 }
4067 #[inline]
4068 fn on_connection_id_updated(
4069 &mut self,
4070 context: &mut Self::ConnectionContext,
4071 _meta: &api::ConnectionMeta,
4072 event: &api::ConnectionIdUpdated,
4073 ) {
4074 let id = context.id();
4075 let api::ConnectionIdUpdated {
4076 path_id,
4077 cid_consumer,
4078 previous,
4079 current,
4080 } = event;
4081 tracing :: event ! (target : "connection_id_updated" , parent : id , tracing :: Level :: DEBUG , { path_id = tracing :: field :: debug (path_id) , cid_consumer = tracing :: field :: debug (cid_consumer) , previous = tracing :: field :: debug (previous) , current = tracing :: field :: debug (current) });
4082 }
4083 #[inline]
4084 fn on_ecn_state_changed(
4085 &mut self,
4086 context: &mut Self::ConnectionContext,
4087 _meta: &api::ConnectionMeta,
4088 event: &api::EcnStateChanged,
4089 ) {
4090 let id = context.id();
4091 let api::EcnStateChanged { path, state } = event;
4092 tracing :: event ! (target : "ecn_state_changed" , parent : id , tracing :: Level :: DEBUG , { path = tracing :: field :: debug (path) , state = tracing :: field :: debug (state) });
4093 }
4094 #[inline]
4095 fn on_connection_migration_denied(
4096 &mut self,
4097 context: &mut Self::ConnectionContext,
4098 _meta: &api::ConnectionMeta,
4099 event: &api::ConnectionMigrationDenied,
4100 ) {
4101 let id = context.id();
4102 let api::ConnectionMigrationDenied { reason } = event;
4103 tracing :: event ! (target : "connection_migration_denied" , parent : id , tracing :: Level :: DEBUG , { reason = tracing :: field :: debug (reason) });
4104 }
4105 #[inline]
4106 fn on_handshake_status_updated(
4107 &mut self,
4108 context: &mut Self::ConnectionContext,
4109 _meta: &api::ConnectionMeta,
4110 event: &api::HandshakeStatusUpdated,
4111 ) {
4112 let id = context.id();
4113 let api::HandshakeStatusUpdated { status } = event;
4114 tracing :: event ! (target : "handshake_status_updated" , parent : id , tracing :: Level :: DEBUG , { status = tracing :: field :: debug (status) });
4115 }
4116 #[inline]
4117 fn on_tls_exporter_ready(
4118 &mut self,
4119 context: &mut Self::ConnectionContext,
4120 _meta: &api::ConnectionMeta,
4121 event: &api::TlsExporterReady,
4122 ) {
4123 let id = context.id();
4124 let api::TlsExporterReady { session } = event;
4125 tracing :: event ! (target : "tls_exporter_ready" , parent : id , tracing :: Level :: DEBUG , { session = tracing :: field :: debug (session) });
4126 }
4127 #[inline]
4128 fn on_tls_handshake_failed(
4129 &mut self,
4130 context: &mut Self::ConnectionContext,
4131 _meta: &api::ConnectionMeta,
4132 event: &api::TlsHandshakeFailed,
4133 ) {
4134 let id = context.id();
4135 let api::TlsHandshakeFailed { session } = event;
4136 tracing :: event ! (target : "tls_handshake_failed" , parent : id , tracing :: Level :: DEBUG , { session = tracing :: field :: debug (session) });
4137 }
4138 #[inline]
4139 fn on_path_challenge_updated(
4140 &mut self,
4141 context: &mut Self::ConnectionContext,
4142 _meta: &api::ConnectionMeta,
4143 event: &api::PathChallengeUpdated,
4144 ) {
4145 let id = context.id();
4146 let api::PathChallengeUpdated {
4147 path_challenge_status,
4148 path,
4149 challenge_data,
4150 } = event;
4151 tracing :: event ! (target : "path_challenge_updated" , parent : id , tracing :: Level :: DEBUG , { path_challenge_status = tracing :: field :: debug (path_challenge_status) , path = tracing :: field :: debug (path) , challenge_data = tracing :: field :: debug (challenge_data) });
4152 }
4153 #[inline]
4154 fn on_tls_client_hello(
4155 &mut self,
4156 context: &mut Self::ConnectionContext,
4157 _meta: &api::ConnectionMeta,
4158 event: &api::TlsClientHello,
4159 ) {
4160 let id = context.id();
4161 let api::TlsClientHello { payload } = event;
4162 tracing :: event ! (target : "tls_client_hello" , parent : id , tracing :: Level :: DEBUG , { payload = tracing :: field :: debug (payload) });
4163 }
4164 #[inline]
4165 fn on_tls_server_hello(
4166 &mut self,
4167 context: &mut Self::ConnectionContext,
4168 _meta: &api::ConnectionMeta,
4169 event: &api::TlsServerHello,
4170 ) {
4171 let id = context.id();
4172 let api::TlsServerHello { payload } = event;
4173 tracing :: event ! (target : "tls_server_hello" , parent : id , tracing :: Level :: DEBUG , { payload = tracing :: field :: debug (payload) });
4174 }
4175 #[inline]
4176 fn on_rx_stream_progress(
4177 &mut self,
4178 context: &mut Self::ConnectionContext,
4179 _meta: &api::ConnectionMeta,
4180 event: &api::RxStreamProgress,
4181 ) {
4182 let id = context.id();
4183 let api::RxStreamProgress { bytes } = event;
4184 tracing :: event ! (target : "rx_stream_progress" , parent : id , tracing :: Level :: DEBUG , { bytes = tracing :: field :: debug (bytes) });
4185 }
4186 #[inline]
4187 fn on_tx_stream_progress(
4188 &mut self,
4189 context: &mut Self::ConnectionContext,
4190 _meta: &api::ConnectionMeta,
4191 event: &api::TxStreamProgress,
4192 ) {
4193 let id = context.id();
4194 let api::TxStreamProgress { bytes } = event;
4195 tracing :: event ! (target : "tx_stream_progress" , parent : id , tracing :: Level :: DEBUG , { bytes = tracing :: field :: debug (bytes) });
4196 }
4197 #[inline]
4198 fn on_keep_alive_timer_expired(
4199 &mut self,
4200 context: &mut Self::ConnectionContext,
4201 _meta: &api::ConnectionMeta,
4202 event: &api::KeepAliveTimerExpired,
4203 ) {
4204 let id = context.id();
4205 let api::KeepAliveTimerExpired { timeout } = event;
4206 tracing :: event ! (target : "keep_alive_timer_expired" , parent : id , tracing :: Level :: DEBUG , { timeout = tracing :: field :: debug (timeout) });
4207 }
4208 #[inline]
4209 fn on_mtu_updated(
4210 &mut self,
4211 context: &mut Self::ConnectionContext,
4212 _meta: &api::ConnectionMeta,
4213 event: &api::MtuUpdated,
4214 ) {
4215 let id = context.id();
4216 let api::MtuUpdated {
4217 path_id,
4218 mtu,
4219 cause,
4220 search_complete,
4221 } = event;
4222 tracing :: event ! (target : "mtu_updated" , parent : id , tracing :: Level :: DEBUG , { path_id = tracing :: field :: debug (path_id) , mtu = tracing :: field :: debug (mtu) , cause = tracing :: field :: debug (cause) , search_complete = tracing :: field :: debug (search_complete) });
4223 }
4224 #[inline]
4225 fn on_slow_start_exited(
4226 &mut self,
4227 context: &mut Self::ConnectionContext,
4228 _meta: &api::ConnectionMeta,
4229 event: &api::SlowStartExited,
4230 ) {
4231 let id = context.id();
4232 let api::SlowStartExited {
4233 path_id,
4234 cause,
4235 congestion_window,
4236 } = event;
4237 tracing :: event ! (target : "slow_start_exited" , parent : id , tracing :: Level :: DEBUG , { path_id = tracing :: field :: debug (path_id) , cause = tracing :: field :: debug (cause) , congestion_window = tracing :: field :: debug (congestion_window) });
4238 }
4239 #[inline]
4240 fn on_delivery_rate_sampled(
4241 &mut self,
4242 context: &mut Self::ConnectionContext,
4243 _meta: &api::ConnectionMeta,
4244 event: &api::DeliveryRateSampled,
4245 ) {
4246 let id = context.id();
4247 let api::DeliveryRateSampled {
4248 path_id,
4249 rate_sample,
4250 } = event;
4251 tracing :: event ! (target : "delivery_rate_sampled" , parent : id , tracing :: Level :: DEBUG , { path_id = tracing :: field :: debug (path_id) , rate_sample = tracing :: field :: debug (rate_sample) });
4252 }
4253 #[inline]
4254 fn on_pacing_rate_updated(
4255 &mut self,
4256 context: &mut Self::ConnectionContext,
4257 _meta: &api::ConnectionMeta,
4258 event: &api::PacingRateUpdated,
4259 ) {
4260 let id = context.id();
4261 let api::PacingRateUpdated {
4262 path_id,
4263 bytes_per_second,
4264 burst_size,
4265 pacing_gain,
4266 } = event;
4267 tracing :: event ! (target : "pacing_rate_updated" , parent : id , tracing :: Level :: DEBUG , { path_id = tracing :: field :: debug (path_id) , bytes_per_second = tracing :: field :: debug (bytes_per_second) , burst_size = tracing :: field :: debug (burst_size) , pacing_gain = tracing :: field :: debug (pacing_gain) });
4268 }
4269 #[inline]
4270 fn on_bbr_state_changed(
4271 &mut self,
4272 context: &mut Self::ConnectionContext,
4273 _meta: &api::ConnectionMeta,
4274 event: &api::BbrStateChanged,
4275 ) {
4276 let id = context.id();
4277 let api::BbrStateChanged { path_id, state } = event;
4278 tracing :: event ! (target : "bbr_state_changed" , parent : id , tracing :: Level :: DEBUG , { path_id = tracing :: field :: debug (path_id) , state = tracing :: field :: debug (state) });
4279 }
4280 #[inline]
4281 fn on_dc_state_changed(
4282 &mut self,
4283 context: &mut Self::ConnectionContext,
4284 _meta: &api::ConnectionMeta,
4285 event: &api::DcStateChanged,
4286 ) {
4287 let id = context.id();
4288 let api::DcStateChanged { state } = event;
4289 tracing :: event ! (target : "dc_state_changed" , parent : id , tracing :: Level :: DEBUG , { state = tracing :: field :: debug (state) });
4290 }
4291 #[inline]
4292 fn on_dc_path_created(
4293 &mut self,
4294 context: &mut Self::ConnectionContext,
4295 _meta: &api::ConnectionMeta,
4296 event: &api::DcPathCreated,
4297 ) {
4298 let id = context.id();
4299 let api::DcPathCreated { path } = event;
4300 tracing :: event ! (target : "dc_path_created" , parent : id , tracing :: Level :: DEBUG , { path = tracing :: field :: debug (path) });
4301 }
4302 #[inline]
4303 fn on_connection_closed(
4304 &mut self,
4305 context: &mut Self::ConnectionContext,
4306 _meta: &api::ConnectionMeta,
4307 event: &api::ConnectionClosed,
4308 ) {
4309 let id = context.id();
4310 let api::ConnectionClosed { error } = event;
4311 tracing :: event ! (target : "connection_closed" , parent : id , tracing :: Level :: DEBUG , { error = tracing :: field :: debug (error) });
4312 }
4313 #[inline]
4314 fn on_version_information(
4315 &mut self,
4316 meta: &api::EndpointMeta,
4317 event: &api::VersionInformation,
4318 ) {
4319 let parent = self.parent(meta);
4320 let api::VersionInformation {
4321 server_versions,
4322 client_versions,
4323 chosen_version,
4324 } = event;
4325 tracing :: event ! (target : "version_information" , parent : parent , tracing :: Level :: DEBUG , { server_versions = tracing :: field :: debug (server_versions) , client_versions = tracing :: field :: debug (client_versions) , chosen_version = tracing :: field :: debug (chosen_version) });
4326 }
4327 #[inline]
4328 fn on_endpoint_packet_sent(
4329 &mut self,
4330 meta: &api::EndpointMeta,
4331 event: &api::EndpointPacketSent,
4332 ) {
4333 let parent = self.parent(meta);
4334 let api::EndpointPacketSent { packet_header } = event;
4335 tracing :: event ! (target : "endpoint_packet_sent" , parent : parent , tracing :: Level :: DEBUG , { packet_header = tracing :: field :: debug (packet_header) });
4336 }
4337 #[inline]
4338 fn on_endpoint_packet_received(
4339 &mut self,
4340 meta: &api::EndpointMeta,
4341 event: &api::EndpointPacketReceived,
4342 ) {
4343 let parent = self.parent(meta);
4344 let api::EndpointPacketReceived { packet_header } = event;
4345 tracing :: event ! (target : "endpoint_packet_received" , parent : parent , tracing :: Level :: DEBUG , { packet_header = tracing :: field :: debug (packet_header) });
4346 }
4347 #[inline]
4348 fn on_endpoint_datagram_sent(
4349 &mut self,
4350 meta: &api::EndpointMeta,
4351 event: &api::EndpointDatagramSent,
4352 ) {
4353 let parent = self.parent(meta);
4354 let api::EndpointDatagramSent { len, gso_offset } = event;
4355 tracing :: event ! (target : "endpoint_datagram_sent" , parent : parent , tracing :: Level :: DEBUG , { len = tracing :: field :: debug (len) , gso_offset = tracing :: field :: debug (gso_offset) });
4356 }
4357 #[inline]
4358 fn on_endpoint_datagram_received(
4359 &mut self,
4360 meta: &api::EndpointMeta,
4361 event: &api::EndpointDatagramReceived,
4362 ) {
4363 let parent = self.parent(meta);
4364 let api::EndpointDatagramReceived { len } = event;
4365 tracing :: event ! (target : "endpoint_datagram_received" , parent : parent , tracing :: Level :: DEBUG , { len = tracing :: field :: debug (len) });
4366 }
4367 #[inline]
4368 fn on_endpoint_datagram_dropped(
4369 &mut self,
4370 meta: &api::EndpointMeta,
4371 event: &api::EndpointDatagramDropped,
4372 ) {
4373 let parent = self.parent(meta);
4374 let api::EndpointDatagramDropped { len, reason } = event;
4375 tracing :: event ! (target : "endpoint_datagram_dropped" , parent : parent , tracing :: Level :: DEBUG , { len = tracing :: field :: debug (len) , reason = tracing :: field :: debug (reason) });
4376 }
4377 #[inline]
4378 fn on_endpoint_connection_attempt_failed(
4379 &mut self,
4380 meta: &api::EndpointMeta,
4381 event: &api::EndpointConnectionAttemptFailed,
4382 ) {
4383 let parent = self.parent(meta);
4384 let api::EndpointConnectionAttemptFailed { error } = event;
4385 tracing :: event ! (target : "endpoint_connection_attempt_failed" , parent : parent , tracing :: Level :: DEBUG , { error = tracing :: field :: debug (error) });
4386 }
4387 #[inline]
4388 fn on_endpoint_connection_attempt_deduplicated(
4389 &mut self,
4390 meta: &api::EndpointMeta,
4391 event: &api::EndpointConnectionAttemptDeduplicated,
4392 ) {
4393 let parent = self.parent(meta);
4394 let api::EndpointConnectionAttemptDeduplicated {
4395 connection_id,
4396 already_open,
4397 } = event;
4398 tracing :: event ! (target : "endpoint_connection_attempt_deduplicated" , parent : parent , tracing :: Level :: DEBUG , { connection_id = tracing :: field :: debug (connection_id) , already_open = tracing :: field :: debug (already_open) });
4399 }
4400 #[inline]
4401 fn on_platform_tx(&mut self, meta: &api::EndpointMeta, event: &api::PlatformTx) {
4402 let parent = self.parent(meta);
4403 let api::PlatformTx {
4404 count,
4405 syscalls,
4406 blocked_syscalls,
4407 total_errors,
4408 dropped_errors,
4409 } = event;
4410 tracing :: event ! (target : "platform_tx" , parent : parent , tracing :: Level :: DEBUG , { count = tracing :: field :: debug (count) , syscalls = tracing :: field :: debug (syscalls) , blocked_syscalls = tracing :: field :: debug (blocked_syscalls) , total_errors = tracing :: field :: debug (total_errors) , dropped_errors = tracing :: field :: debug (dropped_errors) });
4411 }
4412 #[inline]
4413 fn on_platform_tx_error(&mut self, meta: &api::EndpointMeta, event: &api::PlatformTxError) {
4414 let parent = self.parent(meta);
4415 let api::PlatformTxError { errno } = event;
4416 tracing :: event ! (target : "platform_tx_error" , parent : parent , tracing :: Level :: DEBUG , { errno = tracing :: field :: debug (errno) });
4417 }
4418 #[inline]
4419 fn on_platform_rx(&mut self, meta: &api::EndpointMeta, event: &api::PlatformRx) {
4420 let parent = self.parent(meta);
4421 let api::PlatformRx {
4422 count,
4423 syscalls,
4424 blocked_syscalls,
4425 total_errors,
4426 dropped_errors,
4427 } = event;
4428 tracing :: event ! (target : "platform_rx" , parent : parent , tracing :: Level :: DEBUG , { count = tracing :: field :: debug (count) , syscalls = tracing :: field :: debug (syscalls) , blocked_syscalls = tracing :: field :: debug (blocked_syscalls) , total_errors = tracing :: field :: debug (total_errors) , dropped_errors = tracing :: field :: debug (dropped_errors) });
4429 }
4430 #[inline]
4431 fn on_platform_rx_error(&mut self, meta: &api::EndpointMeta, event: &api::PlatformRxError) {
4432 let parent = self.parent(meta);
4433 let api::PlatformRxError { errno } = event;
4434 tracing :: event ! (target : "platform_rx_error" , parent : parent , tracing :: Level :: DEBUG , { errno = tracing :: field :: debug (errno) });
4435 }
4436 #[inline]
4437 fn on_platform_feature_configured(
4438 &mut self,
4439 meta: &api::EndpointMeta,
4440 event: &api::PlatformFeatureConfigured,
4441 ) {
4442 let parent = self.parent(meta);
4443 let api::PlatformFeatureConfigured { configuration } = event;
4444 tracing :: event ! (target : "platform_feature_configured" , parent : parent , tracing :: Level :: DEBUG , { configuration = tracing :: field :: debug (configuration) });
4445 }
4446 #[inline]
4447 fn on_platform_event_loop_wakeup(
4448 &mut self,
4449 meta: &api::EndpointMeta,
4450 event: &api::PlatformEventLoopWakeup,
4451 ) {
4452 let parent = self.parent(meta);
4453 let api::PlatformEventLoopWakeup {
4454 timeout_expired,
4455 rx_ready,
4456 tx_ready,
4457 application_wakeup,
4458 } = event;
4459 tracing :: event ! (target : "platform_event_loop_wakeup" , parent : parent , tracing :: Level :: DEBUG , { timeout_expired = tracing :: field :: debug (timeout_expired) , rx_ready = tracing :: field :: debug (rx_ready) , tx_ready = tracing :: field :: debug (tx_ready) , application_wakeup = tracing :: field :: debug (application_wakeup) });
4460 }
4461 #[inline]
4462 fn on_platform_event_loop_sleep(
4463 &mut self,
4464 meta: &api::EndpointMeta,
4465 event: &api::PlatformEventLoopSleep,
4466 ) {
4467 let parent = self.parent(meta);
4468 let api::PlatformEventLoopSleep {
4469 timeout,
4470 processing_duration,
4471 } = event;
4472 tracing :: event ! (target : "platform_event_loop_sleep" , parent : parent , tracing :: Level :: DEBUG , { timeout = tracing :: field :: debug (timeout) , processing_duration = tracing :: field :: debug (processing_duration) });
4473 }
4474 #[inline]
4475 fn on_platform_event_loop_started(
4476 &mut self,
4477 meta: &api::EndpointMeta,
4478 event: &api::PlatformEventLoopStarted,
4479 ) {
4480 let parent = self.parent(meta);
4481 let api::PlatformEventLoopStarted { local_address } = event;
4482 tracing :: event ! (target : "platform_event_loop_started" , parent : parent , tracing :: Level :: DEBUG , { local_address = tracing :: field :: debug (local_address) });
4483 }
4484 }
4485}
4486pub mod builder {
4487 use super::*;
4488 #[derive(Clone, Debug)]
4489 pub struct ConnectionMeta {
4490 pub endpoint_type: crate::endpoint::Type,
4491 pub id: u64,
4492 pub timestamp: crate::time::Timestamp,
4493 }
4494 impl IntoEvent<api::ConnectionMeta> for ConnectionMeta {
4495 #[inline]
4496 fn into_event(self) -> api::ConnectionMeta {
4497 let ConnectionMeta {
4498 endpoint_type,
4499 id,
4500 timestamp,
4501 } = self;
4502 api::ConnectionMeta {
4503 endpoint_type: endpoint_type.into_event(),
4504 id: id.into_event(),
4505 timestamp: timestamp.into_event(),
4506 }
4507 }
4508 }
4509 #[derive(Clone, Debug)]
4510 pub struct EndpointMeta {
4511 pub endpoint_type: crate::endpoint::Type,
4512 pub timestamp: crate::time::Timestamp,
4513 }
4514 impl IntoEvent<api::EndpointMeta> for EndpointMeta {
4515 #[inline]
4516 fn into_event(self) -> api::EndpointMeta {
4517 let EndpointMeta {
4518 endpoint_type,
4519 timestamp,
4520 } = self;
4521 api::EndpointMeta {
4522 endpoint_type: endpoint_type.into_event(),
4523 timestamp: timestamp.into_event(),
4524 }
4525 }
4526 }
4527 #[derive(Clone, Debug)]
4528 pub struct ConnectionInfo {}
4529 impl IntoEvent<api::ConnectionInfo> for ConnectionInfo {
4530 #[inline]
4531 fn into_event(self) -> api::ConnectionInfo {
4532 let ConnectionInfo {} = self;
4533 api::ConnectionInfo {}
4534 }
4535 }
4536 #[derive(Clone, Debug)]
4537 pub struct TransportParameters<'a> {
4538 pub original_destination_connection_id: Option<ConnectionId<'a>>,
4539 pub initial_source_connection_id: Option<ConnectionId<'a>>,
4540 pub retry_source_connection_id: Option<ConnectionId<'a>>,
4541 pub stateless_reset_token: Option<&'a [u8]>,
4542 pub preferred_address: Option<PreferredAddress<'a>>,
4543 pub migration_support: bool,
4544 pub max_idle_timeout: Duration,
4545 pub ack_delay_exponent: u8,
4546 pub max_ack_delay: Duration,
4547 pub max_udp_payload_size: u64,
4548 pub active_connection_id_limit: u64,
4549 pub initial_max_stream_data_bidi_local: u64,
4550 pub initial_max_stream_data_bidi_remote: u64,
4551 pub initial_max_stream_data_uni: u64,
4552 pub initial_max_streams_bidi: u64,
4553 pub initial_max_streams_uni: u64,
4554 pub max_datagram_frame_size: u64,
4555 pub dc_supported_versions: &'a [u32],
4556 }
4557 impl<'a> IntoEvent<api::TransportParameters<'a>> for TransportParameters<'a> {
4558 #[inline]
4559 fn into_event(self) -> api::TransportParameters<'a> {
4560 let TransportParameters {
4561 original_destination_connection_id,
4562 initial_source_connection_id,
4563 retry_source_connection_id,
4564 stateless_reset_token,
4565 preferred_address,
4566 migration_support,
4567 max_idle_timeout,
4568 ack_delay_exponent,
4569 max_ack_delay,
4570 max_udp_payload_size,
4571 active_connection_id_limit,
4572 initial_max_stream_data_bidi_local,
4573 initial_max_stream_data_bidi_remote,
4574 initial_max_stream_data_uni,
4575 initial_max_streams_bidi,
4576 initial_max_streams_uni,
4577 max_datagram_frame_size,
4578 dc_supported_versions,
4579 } = self;
4580 api::TransportParameters {
4581 original_destination_connection_id: original_destination_connection_id.into_event(),
4582 initial_source_connection_id: initial_source_connection_id.into_event(),
4583 retry_source_connection_id: retry_source_connection_id.into_event(),
4584 stateless_reset_token: stateless_reset_token.into_event(),
4585 preferred_address: preferred_address.into_event(),
4586 migration_support: migration_support.into_event(),
4587 max_idle_timeout: max_idle_timeout.into_event(),
4588 ack_delay_exponent: ack_delay_exponent.into_event(),
4589 max_ack_delay: max_ack_delay.into_event(),
4590 max_udp_payload_size: max_udp_payload_size.into_event(),
4591 active_connection_id_limit: active_connection_id_limit.into_event(),
4592 initial_max_stream_data_bidi_local: initial_max_stream_data_bidi_local.into_event(),
4593 initial_max_stream_data_bidi_remote: initial_max_stream_data_bidi_remote
4594 .into_event(),
4595 initial_max_stream_data_uni: initial_max_stream_data_uni.into_event(),
4596 initial_max_streams_bidi: initial_max_streams_bidi.into_event(),
4597 initial_max_streams_uni: initial_max_streams_uni.into_event(),
4598 max_datagram_frame_size: max_datagram_frame_size.into_event(),
4599 dc_supported_versions: dc_supported_versions.into_event(),
4600 }
4601 }
4602 }
4603 #[derive(Clone, Debug)]
4604 pub struct PreferredAddress<'a> {
4605 pub ipv4_address: Option<SocketAddress<'a>>,
4606 pub ipv6_address: Option<SocketAddress<'a>>,
4607 pub connection_id: ConnectionId<'a>,
4608 pub stateless_reset_token: &'a [u8],
4609 }
4610 impl<'a> IntoEvent<api::PreferredAddress<'a>> for PreferredAddress<'a> {
4611 #[inline]
4612 fn into_event(self) -> api::PreferredAddress<'a> {
4613 let PreferredAddress {
4614 ipv4_address,
4615 ipv6_address,
4616 connection_id,
4617 stateless_reset_token,
4618 } = self;
4619 api::PreferredAddress {
4620 ipv4_address: ipv4_address.into_event(),
4621 ipv6_address: ipv6_address.into_event(),
4622 connection_id: connection_id.into_event(),
4623 stateless_reset_token: stateless_reset_token.into_event(),
4624 }
4625 }
4626 }
4627 #[derive(Copy, Clone, Debug)]
4628 pub struct Path<'a> {
4629 pub local_addr: SocketAddress<'a>,
4630 pub local_cid: ConnectionId<'a>,
4631 pub remote_addr: SocketAddress<'a>,
4632 pub remote_cid: ConnectionId<'a>,
4633 pub id: u64,
4634 pub is_active: bool,
4635 }
4636 impl<'a> IntoEvent<api::Path<'a>> for Path<'a> {
4637 #[inline]
4638 fn into_event(self) -> api::Path<'a> {
4639 let Path {
4640 local_addr,
4641 local_cid,
4642 remote_addr,
4643 remote_cid,
4644 id,
4645 is_active,
4646 } = self;
4647 api::Path {
4648 local_addr: local_addr.into_event(),
4649 local_cid: local_cid.into_event(),
4650 remote_addr: remote_addr.into_event(),
4651 remote_cid: remote_cid.into_event(),
4652 id: id.into_event(),
4653 is_active: is_active.into_event(),
4654 }
4655 }
4656 }
4657 #[derive(Copy, Clone, Debug)]
4658 pub struct ConnectionId<'a> {
4659 pub bytes: &'a [u8],
4660 }
4661 impl<'a> IntoEvent<api::ConnectionId<'a>> for ConnectionId<'a> {
4662 #[inline]
4663 fn into_event(self) -> api::ConnectionId<'a> {
4664 let ConnectionId { bytes } = self;
4665 api::ConnectionId {
4666 bytes: bytes.into_event(),
4667 }
4668 }
4669 }
4670 #[derive(Clone, Debug)]
4671 pub struct EcnCounts {
4672 #[doc = " A variable-length integer representing the total number of packets"]
4673 #[doc = " received with the ECT(0) codepoint."]
4674 pub ect_0_count: u64,
4675 #[doc = " A variable-length integer representing the total number of packets"]
4676 #[doc = " received with the ECT(1) codepoint."]
4677 pub ect_1_count: u64,
4678 #[doc = " A variable-length integer representing the total number of packets"]
4679 #[doc = " received with the CE codepoint."]
4680 pub ce_count: u64,
4681 }
4682 impl IntoEvent<api::EcnCounts> for EcnCounts {
4683 #[inline]
4684 fn into_event(self) -> api::EcnCounts {
4685 let EcnCounts {
4686 ect_0_count,
4687 ect_1_count,
4688 ce_count,
4689 } = self;
4690 api::EcnCounts {
4691 ect_0_count: ect_0_count.into_event(),
4692 ect_1_count: ect_1_count.into_event(),
4693 ce_count: ce_count.into_event(),
4694 }
4695 }
4696 }
4697 #[derive(Clone, Debug)]
4698 pub struct ConnectionCloseFrame<'a> {
4699 pub error_code: u64,
4700 pub frame_type: Option<u64>,
4701 pub reason: Option<&'a [u8]>,
4702 }
4703 impl<'a> IntoEvent<api::ConnectionCloseFrame<'a>> for ConnectionCloseFrame<'a> {
4704 #[inline]
4705 fn into_event(self) -> api::ConnectionCloseFrame<'a> {
4706 let ConnectionCloseFrame {
4707 error_code,
4708 frame_type,
4709 reason,
4710 } = self;
4711 api::ConnectionCloseFrame {
4712 error_code: error_code.into_event(),
4713 frame_type: frame_type.into_event(),
4714 reason: reason.into_event(),
4715 }
4716 }
4717 }
4718 #[derive(Clone, Debug)]
4719 pub struct MtuConfig {
4720 pub initial_mtu: u16,
4721 pub base_mtu: u16,
4722 pub max_mtu: u16,
4723 }
4724 impl IntoEvent<api::MtuConfig> for MtuConfig {
4725 #[inline]
4726 fn into_event(self) -> api::MtuConfig {
4727 let MtuConfig {
4728 initial_mtu,
4729 base_mtu,
4730 max_mtu,
4731 } = self;
4732 api::MtuConfig {
4733 initial_mtu: initial_mtu.into_event(),
4734 base_mtu: base_mtu.into_event(),
4735 max_mtu: max_mtu.into_event(),
4736 }
4737 }
4738 }
4739 #[derive(Clone, Debug)]
4740 #[doc = " A bandwidth delivery rate estimate with associated metadata"]
4741 pub struct RateSample {
4742 #[doc = " The length of the sampling interval"]
4743 pub interval: Duration,
4744 #[doc = " The amount of data in bytes marked as delivered over the sampling interval"]
4745 pub delivered_bytes: u64,
4746 #[doc = " The amount of data in bytes marked as lost over the sampling interval"]
4747 pub lost_bytes: u64,
4748 #[doc = " The number of packets marked as explicit congestion experienced over the sampling interval"]
4749 pub ecn_ce_count: u64,
4750 #[doc = " PacketInfo::is_app_limited from the most recent acknowledged packet"]
4751 pub is_app_limited: bool,
4752 #[doc = " PacketInfo::delivered_bytes from the most recent acknowledged packet"]
4753 pub prior_delivered_bytes: u64,
4754 #[doc = " PacketInfo::bytes_in_flight from the most recent acknowledged packet"]
4755 pub bytes_in_flight: u32,
4756 #[doc = " PacketInfo::lost_bytes from the most recent acknowledged packet"]
4757 pub prior_lost_bytes: u64,
4758 #[doc = " PacketInfo::ecn_ce_count from the most recent acknowledged packet"]
4759 pub prior_ecn_ce_count: u64,
4760 #[doc = " The delivery rate for this rate sample"]
4761 pub delivery_rate_bytes_per_second: u64,
4762 }
4763 impl IntoEvent<api::RateSample> for RateSample {
4764 #[inline]
4765 fn into_event(self) -> api::RateSample {
4766 let RateSample {
4767 interval,
4768 delivered_bytes,
4769 lost_bytes,
4770 ecn_ce_count,
4771 is_app_limited,
4772 prior_delivered_bytes,
4773 bytes_in_flight,
4774 prior_lost_bytes,
4775 prior_ecn_ce_count,
4776 delivery_rate_bytes_per_second,
4777 } = self;
4778 api::RateSample {
4779 interval: interval.into_event(),
4780 delivered_bytes: delivered_bytes.into_event(),
4781 lost_bytes: lost_bytes.into_event(),
4782 ecn_ce_count: ecn_ce_count.into_event(),
4783 is_app_limited: is_app_limited.into_event(),
4784 prior_delivered_bytes: prior_delivered_bytes.into_event(),
4785 bytes_in_flight: bytes_in_flight.into_event(),
4786 prior_lost_bytes: prior_lost_bytes.into_event(),
4787 prior_ecn_ce_count: prior_ecn_ce_count.into_event(),
4788 delivery_rate_bytes_per_second: delivery_rate_bytes_per_second.into_event(),
4789 }
4790 }
4791 }
4792 #[derive(Copy, Clone, Debug)]
4793 pub enum SocketAddress<'a> {
4794 IpV4 { ip: &'a [u8; 4], port: u16 },
4795 IpV6 { ip: &'a [u8; 16], port: u16 },
4796 }
4797 impl<'a> IntoEvent<api::SocketAddress<'a>> for SocketAddress<'a> {
4798 #[inline]
4799 fn into_event(self) -> api::SocketAddress<'a> {
4800 use api::SocketAddress::*;
4801 match self {
4802 Self::IpV4 { ip, port } => IpV4 {
4803 ip: ip.into_event(),
4804 port: port.into_event(),
4805 },
4806 Self::IpV6 { ip, port } => IpV6 {
4807 ip: ip.into_event(),
4808 port: port.into_event(),
4809 },
4810 }
4811 }
4812 }
4813 #[derive(Clone, Debug)]
4814 pub enum DuplicatePacketError {
4815 #[doc = " The packet number was already received and is a duplicate."]
4816 Duplicate,
4817 #[doc = " The received packet number was outside the range of tracked packet numbers."]
4818 #[doc = ""]
4819 #[doc = " This can happen when packets are heavily delayed or reordered. Currently, the maximum"]
4820 #[doc = " amount of reordering is limited to 128 packets. For example, if packet number `142`"]
4821 #[doc = " is received, the allowed range would be limited to `14-142`. If an endpoint received"]
4822 #[doc = " packet `< 14`, it would trigger this event."]
4823 TooOld,
4824 }
4825 impl IntoEvent<api::DuplicatePacketError> for DuplicatePacketError {
4826 #[inline]
4827 fn into_event(self) -> api::DuplicatePacketError {
4828 use api::DuplicatePacketError::*;
4829 match self {
4830 Self::Duplicate => Duplicate {},
4831 Self::TooOld => TooOld {},
4832 }
4833 }
4834 }
4835 #[derive(Clone, Debug)]
4836 pub enum Frame {
4837 Padding,
4838 Ping,
4839 Ack {
4840 ecn_counts: Option<EcnCounts>,
4841 largest_acknowledged: u64,
4842 ack_range_count: u64,
4843 },
4844 ResetStream {
4845 id: u64,
4846 error_code: u64,
4847 final_size: u64,
4848 },
4849 StopSending {
4850 id: u64,
4851 error_code: u64,
4852 },
4853 Crypto {
4854 offset: u64,
4855 len: u16,
4856 },
4857 NewToken,
4858 Stream {
4859 id: u64,
4860 offset: u64,
4861 len: u16,
4862 is_fin: bool,
4863 },
4864 MaxData {
4865 value: u64,
4866 },
4867 MaxStreamData {
4868 stream_type: StreamType,
4869 id: u64,
4870 value: u64,
4871 },
4872 MaxStreams {
4873 stream_type: StreamType,
4874 value: u64,
4875 },
4876 DataBlocked {
4877 data_limit: u64,
4878 },
4879 StreamDataBlocked {
4880 stream_id: u64,
4881 stream_data_limit: u64,
4882 },
4883 StreamsBlocked {
4884 stream_type: StreamType,
4885 stream_limit: u64,
4886 },
4887 NewConnectionId {
4888 sequence_number: u64,
4889 retire_prior_to: u64,
4890 },
4891 RetireConnectionId,
4892 PathChallenge,
4893 PathResponse,
4894 ConnectionClose,
4895 HandshakeDone,
4896 Datagram {
4897 len: u16,
4898 },
4899 DcStatelessResetTokens,
4900 }
4901 impl IntoEvent<api::Frame> for Frame {
4902 #[inline]
4903 fn into_event(self) -> api::Frame {
4904 use api::Frame::*;
4905 match self {
4906 Self::Padding => Padding {},
4907 Self::Ping => Ping {},
4908 Self::Ack {
4909 ecn_counts,
4910 largest_acknowledged,
4911 ack_range_count,
4912 } => Ack {
4913 ecn_counts: ecn_counts.into_event(),
4914 largest_acknowledged: largest_acknowledged.into_event(),
4915 ack_range_count: ack_range_count.into_event(),
4916 },
4917 Self::ResetStream {
4918 id,
4919 error_code,
4920 final_size,
4921 } => ResetStream {
4922 id: id.into_event(),
4923 error_code: error_code.into_event(),
4924 final_size: final_size.into_event(),
4925 },
4926 Self::StopSending { id, error_code } => StopSending {
4927 id: id.into_event(),
4928 error_code: error_code.into_event(),
4929 },
4930 Self::Crypto { offset, len } => Crypto {
4931 offset: offset.into_event(),
4932 len: len.into_event(),
4933 },
4934 Self::NewToken => NewToken {},
4935 Self::Stream {
4936 id,
4937 offset,
4938 len,
4939 is_fin,
4940 } => Stream {
4941 id: id.into_event(),
4942 offset: offset.into_event(),
4943 len: len.into_event(),
4944 is_fin: is_fin.into_event(),
4945 },
4946 Self::MaxData { value } => MaxData {
4947 value: value.into_event(),
4948 },
4949 Self::MaxStreamData {
4950 stream_type,
4951 id,
4952 value,
4953 } => MaxStreamData {
4954 stream_type: stream_type.into_event(),
4955 id: id.into_event(),
4956 value: value.into_event(),
4957 },
4958 Self::MaxStreams { stream_type, value } => MaxStreams {
4959 stream_type: stream_type.into_event(),
4960 value: value.into_event(),
4961 },
4962 Self::DataBlocked { data_limit } => DataBlocked {
4963 data_limit: data_limit.into_event(),
4964 },
4965 Self::StreamDataBlocked {
4966 stream_id,
4967 stream_data_limit,
4968 } => StreamDataBlocked {
4969 stream_id: stream_id.into_event(),
4970 stream_data_limit: stream_data_limit.into_event(),
4971 },
4972 Self::StreamsBlocked {
4973 stream_type,
4974 stream_limit,
4975 } => StreamsBlocked {
4976 stream_type: stream_type.into_event(),
4977 stream_limit: stream_limit.into_event(),
4978 },
4979 Self::NewConnectionId {
4980 sequence_number,
4981 retire_prior_to,
4982 } => NewConnectionId {
4983 sequence_number: sequence_number.into_event(),
4984 retire_prior_to: retire_prior_to.into_event(),
4985 },
4986 Self::RetireConnectionId => RetireConnectionId {},
4987 Self::PathChallenge => PathChallenge {},
4988 Self::PathResponse => PathResponse {},
4989 Self::ConnectionClose => ConnectionClose {},
4990 Self::HandshakeDone => HandshakeDone {},
4991 Self::Datagram { len } => Datagram {
4992 len: len.into_event(),
4993 },
4994 Self::DcStatelessResetTokens => DcStatelessResetTokens {},
4995 }
4996 }
4997 }
4998 #[derive(Clone, Debug)]
4999 pub enum StreamType {
5000 Bidirectional,
5001 Unidirectional,
5002 }
5003 impl IntoEvent<api::StreamType> for StreamType {
5004 #[inline]
5005 fn into_event(self) -> api::StreamType {
5006 use api::StreamType::*;
5007 match self {
5008 Self::Bidirectional => Bidirectional {},
5009 Self::Unidirectional => Unidirectional {},
5010 }
5011 }
5012 }
5013 #[derive(Clone, Debug)]
5014 pub enum PacketHeader {
5015 Initial { number: u64, version: u32 },
5016 Handshake { number: u64, version: u32 },
5017 ZeroRtt { number: u64, version: u32 },
5018 OneRtt { number: u64 },
5019 Retry { version: u32 },
5020 VersionNegotiation,
5021 StatelessReset,
5022 }
5023 impl IntoEvent<api::PacketHeader> for PacketHeader {
5024 #[inline]
5025 fn into_event(self) -> api::PacketHeader {
5026 use api::PacketHeader::*;
5027 match self {
5028 Self::Initial { number, version } => Initial {
5029 number: number.into_event(),
5030 version: version.into_event(),
5031 },
5032 Self::Handshake { number, version } => Handshake {
5033 number: number.into_event(),
5034 version: version.into_event(),
5035 },
5036 Self::ZeroRtt { number, version } => ZeroRtt {
5037 number: number.into_event(),
5038 version: version.into_event(),
5039 },
5040 Self::OneRtt { number } => OneRtt {
5041 number: number.into_event(),
5042 },
5043 Self::Retry { version } => Retry {
5044 version: version.into_event(),
5045 },
5046 Self::VersionNegotiation => VersionNegotiation {},
5047 Self::StatelessReset => StatelessReset {},
5048 }
5049 }
5050 }
5051 #[derive(Clone, Debug)]
5052 pub enum PacketType {
5053 Initial,
5054 Handshake,
5055 ZeroRtt,
5056 OneRtt,
5057 Retry,
5058 VersionNegotiation,
5059 StatelessReset,
5060 }
5061 impl IntoEvent<api::PacketType> for PacketType {
5062 #[inline]
5063 fn into_event(self) -> api::PacketType {
5064 use api::PacketType::*;
5065 match self {
5066 Self::Initial => Initial {},
5067 Self::Handshake => Handshake {},
5068 Self::ZeroRtt => ZeroRtt {},
5069 Self::OneRtt => OneRtt {},
5070 Self::Retry => Retry {},
5071 Self::VersionNegotiation => VersionNegotiation {},
5072 Self::StatelessReset => StatelessReset {},
5073 }
5074 }
5075 }
5076 #[derive(Clone, Debug)]
5077 pub enum KeyType {
5078 Initial,
5079 Handshake,
5080 ZeroRtt,
5081 OneRtt { generation: u16 },
5082 }
5083 impl IntoEvent<api::KeyType> for KeyType {
5084 #[inline]
5085 fn into_event(self) -> api::KeyType {
5086 use api::KeyType::*;
5087 match self {
5088 Self::Initial => Initial {},
5089 Self::Handshake => Handshake {},
5090 Self::ZeroRtt => ZeroRtt {},
5091 Self::OneRtt { generation } => OneRtt {
5092 generation: generation.into_event(),
5093 },
5094 }
5095 }
5096 }
5097 #[derive(Clone, Debug)]
5098 #[doc = " A context from which the event is being emitted"]
5099 #[doc = ""]
5100 #[doc = " An event can occur in the context of an Endpoint or Connection"]
5101 pub enum Subject {
5102 Endpoint,
5103 #[doc = " This maps to an internal connection id, which is a stable identifier across CID changes."]
5104 Connection {
5105 id: u64,
5106 },
5107 }
5108 impl IntoEvent<api::Subject> for Subject {
5109 #[inline]
5110 fn into_event(self) -> api::Subject {
5111 use api::Subject::*;
5112 match self {
5113 Self::Endpoint => Endpoint {},
5114 Self::Connection { id } => Connection {
5115 id: id.into_event(),
5116 },
5117 }
5118 }
5119 }
5120 #[derive(Clone, Debug)]
5121 #[doc = " An endpoint may be either a Server or a Client"]
5122 pub enum EndpointType {
5123 Server,
5124 Client,
5125 }
5126 impl IntoEvent<api::EndpointType> for EndpointType {
5127 #[inline]
5128 fn into_event(self) -> api::EndpointType {
5129 use api::EndpointType::*;
5130 match self {
5131 Self::Server => Server {},
5132 Self::Client => Client {},
5133 }
5134 }
5135 }
5136 #[derive(Clone, Debug)]
5137 pub enum DatagramDropReason {
5138 #[doc = " There was an error while attempting to decode the datagram."]
5139 DecodingFailed,
5140 #[doc = " There was an error while parsing the Retry token."]
5141 InvalidRetryToken,
5142 #[doc = " The peer specified an unsupported QUIC version."]
5143 UnsupportedVersion,
5144 #[doc = " The peer sent an invalid Destination Connection Id."]
5145 InvalidDestinationConnectionId,
5146 #[doc = " The peer sent an invalid Source Connection Id."]
5147 InvalidSourceConnectionId,
5148 #[doc = " Application provided invalid MTU configuration."]
5149 InvalidMtuConfiguration {
5150 #[doc = " MTU configuration for the endpoint"]
5151 endpoint_mtu_config: MtuConfig,
5152 },
5153 #[doc = " The Destination Connection Id is unknown and does not map to a Connection."]
5154 #[doc = ""]
5155 #[doc = " Connections are mapped to Destination Connections Ids (DCID) and packets"]
5156 #[doc = " in a Datagram are routed to a connection based on the DCID in the first"]
5157 #[doc = " packet. If a Connection is not found for the specified DCID then the"]
5158 #[doc = " datagram can not be processed and is dropped."]
5159 UnknownDestinationConnectionId,
5160 #[doc = " The connection attempt was rejected."]
5161 RejectedConnectionAttempt,
5162 #[doc = " A datagram was received from an unknown server address."]
5163 UnknownServerAddress,
5164 #[doc = " The peer initiated a connection migration before the handshake was confirmed."]
5165 #[doc = ""]
5166 #[doc = " Note: This drop reason is no longer emitted"]
5167 ConnectionMigrationDuringHandshake,
5168 #[doc = " The attempted connection migration was rejected."]
5169 RejectedConnectionMigration { reason: MigrationDenyReason },
5170 #[doc = " The maximum number of paths per connection was exceeded."]
5171 PathLimitExceeded,
5172 #[doc = " The peer initiated a connection migration without supplying enough connection IDs to use."]
5173 #[doc = ""]
5174 #[doc = " Note: This drop reason is no longer emitted"]
5175 InsufficientConnectionIds,
5176 }
5177 impl IntoEvent<api::DatagramDropReason> for DatagramDropReason {
5178 #[inline]
5179 fn into_event(self) -> api::DatagramDropReason {
5180 use api::DatagramDropReason::*;
5181 match self {
5182 Self::DecodingFailed => DecodingFailed {},
5183 Self::InvalidRetryToken => InvalidRetryToken {},
5184 Self::UnsupportedVersion => UnsupportedVersion {},
5185 Self::InvalidDestinationConnectionId => InvalidDestinationConnectionId {},
5186 Self::InvalidSourceConnectionId => InvalidSourceConnectionId {},
5187 Self::InvalidMtuConfiguration {
5188 endpoint_mtu_config,
5189 } => InvalidMtuConfiguration {
5190 endpoint_mtu_config: endpoint_mtu_config.into_event(),
5191 },
5192 Self::UnknownDestinationConnectionId => UnknownDestinationConnectionId {},
5193 Self::RejectedConnectionAttempt => RejectedConnectionAttempt {},
5194 Self::UnknownServerAddress => UnknownServerAddress {},
5195 Self::ConnectionMigrationDuringHandshake => ConnectionMigrationDuringHandshake {},
5196 Self::RejectedConnectionMigration { reason } => RejectedConnectionMigration {
5197 reason: reason.into_event(),
5198 },
5199 Self::PathLimitExceeded => PathLimitExceeded {},
5200 Self::InsufficientConnectionIds => InsufficientConnectionIds {},
5201 }
5202 }
5203 }
5204 #[derive(Clone, Debug)]
5205 pub enum KeySpace {
5206 Initial,
5207 Handshake,
5208 ZeroRtt,
5209 OneRtt,
5210 }
5211 impl IntoEvent<api::KeySpace> for KeySpace {
5212 #[inline]
5213 fn into_event(self) -> api::KeySpace {
5214 use api::KeySpace::*;
5215 match self {
5216 Self::Initial => Initial {},
5217 Self::Handshake => Handshake {},
5218 Self::ZeroRtt => ZeroRtt {},
5219 Self::OneRtt => OneRtt {},
5220 }
5221 }
5222 }
5223 #[derive(Clone, Debug)]
5224 pub enum PacketSkipReason {
5225 #[doc = " Skipped a packet number to elicit a quicker PTO acknowledgment"]
5226 PtoProbe,
5227 #[doc = " Skipped a packet number to detect an Optimistic Ack attack"]
5228 OptimisticAckMitigation,
5229 }
5230 impl IntoEvent<api::PacketSkipReason> for PacketSkipReason {
5231 #[inline]
5232 fn into_event(self) -> api::PacketSkipReason {
5233 use api::PacketSkipReason::*;
5234 match self {
5235 Self::PtoProbe => PtoProbe {},
5236 Self::OptimisticAckMitigation => OptimisticAckMitigation {},
5237 }
5238 }
5239 }
5240 #[derive(Clone, Debug)]
5241 pub enum PacketDropReason<'a> {
5242 #[doc = " A connection error occurred and is no longer able to process packets."]
5243 ConnectionError { path: Path<'a> },
5244 #[doc = " The handshake needed to be complete before processing the packet."]
5245 #[doc = ""]
5246 #[doc = " To ensure the connection stays secure, short packets can only be processed"]
5247 #[doc = " once the handshake has completed."]
5248 HandshakeNotComplete { path: Path<'a> },
5249 #[doc = " The packet contained a version which did not match the version negotiated"]
5250 #[doc = " during the handshake."]
5251 VersionMismatch { version: u32, path: Path<'a> },
5252 #[doc = " A datagram contained more than one destination connection ID, which is"]
5253 #[doc = " not allowed."]
5254 ConnectionIdMismatch {
5255 packet_cid: &'a [u8],
5256 path: Path<'a>,
5257 },
5258 #[doc = " There was a failure when attempting to remove header protection."]
5259 UnprotectFailed { space: KeySpace, path: Path<'a> },
5260 #[doc = " There was a failure when attempting to decrypt the packet."]
5261 DecryptionFailed {
5262 path: Path<'a>,
5263 packet_header: PacketHeader,
5264 },
5265 #[doc = " Packet decoding failed."]
5266 #[doc = ""]
5267 #[doc = " The payload is decoded one packet at a time. If decoding fails"]
5268 #[doc = " then the remaining packets are also discarded."]
5269 DecodingFailed { path: Path<'a> },
5270 #[doc = " The client received a non-empty retry token."]
5271 NonEmptyRetryToken { path: Path<'a> },
5272 #[doc = " A Retry packet was discarded."]
5273 RetryDiscarded {
5274 reason: RetryDiscardReason<'a>,
5275 path: Path<'a>,
5276 },
5277 #[doc = " The received Initial packet was not transported in a datagram of at least 1200 bytes"]
5278 UndersizedInitialPacket { path: Path<'a> },
5279 #[doc = " The destination connection ID in the packet was the initial connection ID but was in"]
5280 #[doc = " a non-initial packet."]
5281 InitialConnectionIdInvalidSpace {
5282 path: Path<'a>,
5283 packet_type: PacketType,
5284 },
5285 #[doc = " The packet space for a received packet did not exist"]
5286 PacketSpaceDoesNotExist {
5287 path: Path<'a>,
5288 packet_type: PacketType,
5289 },
5290 }
5291 impl<'a> IntoEvent<api::PacketDropReason<'a>> for PacketDropReason<'a> {
5292 #[inline]
5293 fn into_event(self) -> api::PacketDropReason<'a> {
5294 use api::PacketDropReason::*;
5295 match self {
5296 Self::ConnectionError { path } => ConnectionError {
5297 path: path.into_event(),
5298 },
5299 Self::HandshakeNotComplete { path } => HandshakeNotComplete {
5300 path: path.into_event(),
5301 },
5302 Self::VersionMismatch { version, path } => VersionMismatch {
5303 version: version.into_event(),
5304 path: path.into_event(),
5305 },
5306 Self::ConnectionIdMismatch { packet_cid, path } => ConnectionIdMismatch {
5307 packet_cid: packet_cid.into_event(),
5308 path: path.into_event(),
5309 },
5310 Self::UnprotectFailed { space, path } => UnprotectFailed {
5311 space: space.into_event(),
5312 path: path.into_event(),
5313 },
5314 Self::DecryptionFailed {
5315 path,
5316 packet_header,
5317 } => DecryptionFailed {
5318 path: path.into_event(),
5319 packet_header: packet_header.into_event(),
5320 },
5321 Self::DecodingFailed { path } => DecodingFailed {
5322 path: path.into_event(),
5323 },
5324 Self::NonEmptyRetryToken { path } => NonEmptyRetryToken {
5325 path: path.into_event(),
5326 },
5327 Self::RetryDiscarded { reason, path } => RetryDiscarded {
5328 reason: reason.into_event(),
5329 path: path.into_event(),
5330 },
5331 Self::UndersizedInitialPacket { path } => UndersizedInitialPacket {
5332 path: path.into_event(),
5333 },
5334 Self::InitialConnectionIdInvalidSpace { path, packet_type } => {
5335 InitialConnectionIdInvalidSpace {
5336 path: path.into_event(),
5337 packet_type: packet_type.into_event(),
5338 }
5339 }
5340 Self::PacketSpaceDoesNotExist { path, packet_type } => PacketSpaceDoesNotExist {
5341 path: path.into_event(),
5342 packet_type: packet_type.into_event(),
5343 },
5344 }
5345 }
5346 }
5347 #[derive(Clone, Debug)]
5348 pub enum AckAction {
5349 #[doc = " Ack range for received packets was dropped due to space constraints"]
5350 #[doc = ""]
5351 #[doc = " For the purpose of processing Acks, RX packet numbers are stored as"]
5352 #[doc = " packet_number ranges in an IntervalSet; only lower and upper bounds"]
5353 #[doc = " are stored instead of individual packet_numbers. Ranges are merged"]
5354 #[doc = " when possible so only disjointed ranges are stored."]
5355 #[doc = ""]
5356 #[doc = " When at `capacity`, the lowest packet_number range is dropped."]
5357 RxAckRangeDropped {
5358 #[doc = " The packet number range which was dropped"]
5359 packet_number_range: core::ops::RangeInclusive<u64>,
5360 #[doc = " The number of disjoint ranges the IntervalSet can store"]
5361 capacity: usize,
5362 #[doc = " The store packet_number range in the IntervalSet"]
5363 stored_range: core::ops::RangeInclusive<u64>,
5364 },
5365 }
5366 #[allow(deprecated)]
5367 impl IntoEvent<api::AckAction> for AckAction {
5368 #[inline]
5369 fn into_event(self) -> api::AckAction {
5370 use api::AckAction::*;
5371 match self {
5372 Self::RxAckRangeDropped {
5373 packet_number_range,
5374 capacity,
5375 stored_range,
5376 } => RxAckRangeDropped {
5377 packet_number_range: packet_number_range.into_event(),
5378 capacity: capacity.into_event(),
5379 stored_range: stored_range.into_event(),
5380 },
5381 }
5382 }
5383 }
5384 #[derive(Clone, Debug)]
5385 pub enum RetryDiscardReason<'a> {
5386 #[doc = " Received a Retry packet with SCID field equal to DCID field."]
5387 ScidEqualsDcid { cid: &'a [u8] },
5388 #[doc = " A client only processes at most one Retry packet."]
5389 RetryAlreadyProcessed,
5390 #[doc = " The client discards Retry packets if a valid Initial packet"]
5391 #[doc = " has been received and processed."]
5392 InitialAlreadyProcessed,
5393 #[doc = " The Retry packet received contained an invalid retry integrity tag"]
5394 InvalidIntegrityTag,
5395 }
5396 impl<'a> IntoEvent<api::RetryDiscardReason<'a>> for RetryDiscardReason<'a> {
5397 #[inline]
5398 fn into_event(self) -> api::RetryDiscardReason<'a> {
5399 use api::RetryDiscardReason::*;
5400 match self {
5401 Self::ScidEqualsDcid { cid } => ScidEqualsDcid {
5402 cid: cid.into_event(),
5403 },
5404 Self::RetryAlreadyProcessed => RetryAlreadyProcessed {},
5405 Self::InitialAlreadyProcessed => InitialAlreadyProcessed {},
5406 Self::InvalidIntegrityTag => InvalidIntegrityTag {},
5407 }
5408 }
5409 }
5410 #[derive(Clone, Debug)]
5411 pub enum MigrationDenyReason {
5412 BlockedPort,
5413 PortScopeChanged,
5414 IpScopeChange,
5415 ConnectionMigrationDisabled,
5416 }
5417 impl IntoEvent<api::MigrationDenyReason> for MigrationDenyReason {
5418 #[inline]
5419 fn into_event(self) -> api::MigrationDenyReason {
5420 use api::MigrationDenyReason::*;
5421 match self {
5422 Self::BlockedPort => BlockedPort {},
5423 Self::PortScopeChanged => PortScopeChanged {},
5424 Self::IpScopeChange => IpScopeChange {},
5425 Self::ConnectionMigrationDisabled => ConnectionMigrationDisabled {},
5426 }
5427 }
5428 }
5429 #[derive(Clone, Debug)]
5430 #[doc = " The current state of the ECN controller for the path"]
5431 pub enum EcnState {
5432 #[doc = " ECN capability is being actively tested"]
5433 Testing,
5434 #[doc = " ECN capability has been tested, but not validated yet"]
5435 Unknown,
5436 #[doc = " ECN capability testing has failed validation"]
5437 Failed,
5438 #[doc = " ECN capability has been confirmed"]
5439 Capable,
5440 }
5441 impl IntoEvent<api::EcnState> for EcnState {
5442 #[inline]
5443 fn into_event(self) -> api::EcnState {
5444 use api::EcnState::*;
5445 match self {
5446 Self::Testing => Testing {},
5447 Self::Unknown => Unknown {},
5448 Self::Failed => Failed {},
5449 Self::Capable => Capable {},
5450 }
5451 }
5452 }
5453 #[derive(Clone, Debug)]
5454 #[doc = " Events tracking the progress of handshake status"]
5455 pub enum HandshakeStatus {
5456 #[doc = " The handshake has completed."]
5457 Complete,
5458 #[doc = " The handshake has been confirmed."]
5459 Confirmed,
5460 #[doc = " A HANDSHAKE_DONE frame was delivered or received."]
5461 #[doc = ""]
5462 #[doc = " A Client endpoint receives a HANDSHAKE_DONE frame and"]
5463 #[doc = " only a Server is allowed to send the HANDSHAKE_DONE"]
5464 #[doc = " frame."]
5465 HandshakeDoneAcked,
5466 #[doc = " A HANDSHAKE_DONE frame was declared lost."]
5467 #[doc = ""]
5468 #[doc = " The Server is responsible for re-transmitting the"]
5469 #[doc = " HANDSHAKE_DONE frame until it is acked by the peer."]
5470 HandshakeDoneLost,
5471 }
5472 impl IntoEvent<api::HandshakeStatus> for HandshakeStatus {
5473 #[inline]
5474 fn into_event(self) -> api::HandshakeStatus {
5475 use api::HandshakeStatus::*;
5476 match self {
5477 Self::Complete => Complete {},
5478 Self::Confirmed => Confirmed {},
5479 Self::HandshakeDoneAcked => HandshakeDoneAcked {},
5480 Self::HandshakeDoneLost => HandshakeDoneLost {},
5481 }
5482 }
5483 }
5484 #[derive(Clone, Debug)]
5485 #[doc = " The source that caused a congestion event"]
5486 pub enum CongestionSource {
5487 #[doc = " Explicit Congestion Notification"]
5488 Ecn,
5489 #[doc = " One or more packets were detected lost"]
5490 PacketLoss,
5491 }
5492 impl IntoEvent<api::CongestionSource> for CongestionSource {
5493 #[inline]
5494 fn into_event(self) -> api::CongestionSource {
5495 use api::CongestionSource::*;
5496 match self {
5497 Self::Ecn => Ecn {},
5498 Self::PacketLoss => PacketLoss {},
5499 }
5500 }
5501 }
5502 #[derive(Clone, Debug)]
5503 #[allow(non_camel_case_types)]
5504 pub enum CipherSuite {
5505 TLS_AES_128_GCM_SHA256,
5506 TLS_AES_256_GCM_SHA384,
5507 TLS_CHACHA20_POLY1305_SHA256,
5508 Unknown,
5509 }
5510 impl IntoEvent<api::CipherSuite> for CipherSuite {
5511 #[inline]
5512 fn into_event(self) -> api::CipherSuite {
5513 use api::CipherSuite::*;
5514 match self {
5515 Self::TLS_AES_128_GCM_SHA256 => TLS_AES_128_GCM_SHA256 {},
5516 Self::TLS_AES_256_GCM_SHA384 => TLS_AES_256_GCM_SHA384 {},
5517 Self::TLS_CHACHA20_POLY1305_SHA256 => TLS_CHACHA20_POLY1305_SHA256 {},
5518 Self::Unknown => Unknown {},
5519 }
5520 }
5521 }
5522 #[derive(Clone, Debug)]
5523 pub enum PathChallengeStatus {
5524 Validated,
5525 Abandoned,
5526 }
5527 impl IntoEvent<api::PathChallengeStatus> for PathChallengeStatus {
5528 #[inline]
5529 fn into_event(self) -> api::PathChallengeStatus {
5530 use api::PathChallengeStatus::*;
5531 match self {
5532 Self::Validated => Validated {},
5533 Self::Abandoned => Abandoned {},
5534 }
5535 }
5536 }
5537 #[derive(Clone, Debug)]
5538 #[doc = " The reason the slow start congestion controller state has been exited"]
5539 pub enum SlowStartExitCause {
5540 #[doc = " A packet was determined lost"]
5541 PacketLoss,
5542 #[doc = " An Explicit Congestion Notification: Congestion Experienced marking was received"]
5543 Ecn,
5544 #[doc = " The round trip time estimate was updated"]
5545 Rtt,
5546 #[doc = " Slow Start exited due to a reason other than those above"]
5547 #[doc = ""]
5548 #[doc = " With the Cubic congestion controller, this reason is used after the initial exiting of"]
5549 #[doc = " Slow Start, when the previously determined Slow Start threshold is exceed by the"]
5550 #[doc = " congestion window."]
5551 Other,
5552 }
5553 impl IntoEvent<api::SlowStartExitCause> for SlowStartExitCause {
5554 #[inline]
5555 fn into_event(self) -> api::SlowStartExitCause {
5556 use api::SlowStartExitCause::*;
5557 match self {
5558 Self::PacketLoss => PacketLoss {},
5559 Self::Ecn => Ecn {},
5560 Self::Rtt => Rtt {},
5561 Self::Other => Other {},
5562 }
5563 }
5564 }
5565 #[derive(Clone, Debug)]
5566 #[doc = " The reason the MTU was updated"]
5567 pub enum MtuUpdatedCause {
5568 #[doc = " The MTU was initialized with the default value"]
5569 NewPath,
5570 #[doc = " An MTU probe was acknowledged by the peer"]
5571 ProbeAcknowledged,
5572 #[doc = " A blackhole was detected"]
5573 Blackhole,
5574 #[doc = " An early packet using the configured InitialMtu was lost"]
5575 InitialMtuPacketLost,
5576 #[doc = " An early packet using the configured InitialMtu was acknowledged by the peer"]
5577 InitialMtuPacketAcknowledged,
5578 #[doc = " MTU probes larger than the current MTU were not acknowledged"]
5579 LargerProbesLost,
5580 }
5581 impl IntoEvent<api::MtuUpdatedCause> for MtuUpdatedCause {
5582 #[inline]
5583 fn into_event(self) -> api::MtuUpdatedCause {
5584 use api::MtuUpdatedCause::*;
5585 match self {
5586 Self::NewPath => NewPath {},
5587 Self::ProbeAcknowledged => ProbeAcknowledged {},
5588 Self::Blackhole => Blackhole {},
5589 Self::InitialMtuPacketLost => InitialMtuPacketLost {},
5590 Self::InitialMtuPacketAcknowledged => InitialMtuPacketAcknowledged {},
5591 Self::LargerProbesLost => LargerProbesLost {},
5592 }
5593 }
5594 }
5595 #[derive(Clone, Debug)]
5596 pub enum BbrState {
5597 Startup,
5598 Drain,
5599 ProbeBwDown,
5600 ProbeBwCruise,
5601 ProbeBwRefill,
5602 ProbeBwUp,
5603 ProbeRtt,
5604 }
5605 impl IntoEvent<api::BbrState> for BbrState {
5606 #[inline]
5607 fn into_event(self) -> api::BbrState {
5608 use api::BbrState::*;
5609 match self {
5610 Self::Startup => Startup {},
5611 Self::Drain => Drain {},
5612 Self::ProbeBwDown => ProbeBwDown {},
5613 Self::ProbeBwCruise => ProbeBwCruise {},
5614 Self::ProbeBwRefill => ProbeBwRefill {},
5615 Self::ProbeBwUp => ProbeBwUp {},
5616 Self::ProbeRtt => ProbeRtt {},
5617 }
5618 }
5619 }
5620 #[derive(Clone, Debug)]
5621 pub enum DcState {
5622 VersionNegotiated { version: u32 },
5623 NoVersionNegotiated,
5624 PathSecretsReady,
5625 Complete,
5626 }
5627 impl IntoEvent<api::DcState> for DcState {
5628 #[inline]
5629 fn into_event(self) -> api::DcState {
5630 use api::DcState::*;
5631 match self {
5632 Self::VersionNegotiated { version } => VersionNegotiated {
5633 version: version.into_event(),
5634 },
5635 Self::NoVersionNegotiated => NoVersionNegotiated {},
5636 Self::PathSecretsReady => PathSecretsReady {},
5637 Self::Complete => Complete {},
5638 }
5639 }
5640 }
5641 #[derive(Clone, Debug)]
5642 #[doc = " Application level protocol"]
5643 pub struct ApplicationProtocolInformation<'a> {
5644 pub chosen_application_protocol: &'a [u8],
5645 }
5646 impl<'a> IntoEvent<api::ApplicationProtocolInformation<'a>> for ApplicationProtocolInformation<'a> {
5647 #[inline]
5648 fn into_event(self) -> api::ApplicationProtocolInformation<'a> {
5649 let ApplicationProtocolInformation {
5650 chosen_application_protocol,
5651 } = self;
5652 api::ApplicationProtocolInformation {
5653 chosen_application_protocol: chosen_application_protocol.into_event(),
5654 }
5655 }
5656 }
5657 #[derive(Clone, Debug)]
5658 #[doc = " Server Name was negotiated for the connection"]
5659 pub struct ServerNameInformation<'a> {
5660 pub chosen_server_name: &'a str,
5661 }
5662 impl<'a> IntoEvent<api::ServerNameInformation<'a>> for ServerNameInformation<'a> {
5663 #[inline]
5664 fn into_event(self) -> api::ServerNameInformation<'a> {
5665 let ServerNameInformation { chosen_server_name } = self;
5666 api::ServerNameInformation {
5667 chosen_server_name: chosen_server_name.into_event(),
5668 }
5669 }
5670 }
5671 #[derive(Clone, Debug)]
5672 #[doc = " Key Exchange Group was negotiated for the connection"]
5673 #[doc = ""]
5674 #[doc = " `contains_kem` is `true` if the `chosen_group_name`"]
5675 #[doc = " contains a key encapsulation mechanism"]
5676 pub struct KeyExchangeGroup<'a> {
5677 pub chosen_group_name: &'a str,
5678 pub contains_kem: bool,
5679 }
5680 impl<'a> IntoEvent<api::KeyExchangeGroup<'a>> for KeyExchangeGroup<'a> {
5681 #[inline]
5682 fn into_event(self) -> api::KeyExchangeGroup<'a> {
5683 let KeyExchangeGroup {
5684 chosen_group_name,
5685 contains_kem,
5686 } = self;
5687 api::KeyExchangeGroup {
5688 chosen_group_name: chosen_group_name.into_event(),
5689 contains_kem: contains_kem.into_event(),
5690 }
5691 }
5692 }
5693 #[derive(Clone, Debug)]
5694 #[doc = " Packet was skipped with a given reason"]
5695 pub struct PacketSkipped {
5696 pub number: u64,
5697 pub space: KeySpace,
5698 pub reason: PacketSkipReason,
5699 }
5700 impl IntoEvent<api::PacketSkipped> for PacketSkipped {
5701 #[inline]
5702 fn into_event(self) -> api::PacketSkipped {
5703 let PacketSkipped {
5704 number,
5705 space,
5706 reason,
5707 } = self;
5708 api::PacketSkipped {
5709 number: number.into_event(),
5710 space: space.into_event(),
5711 reason: reason.into_event(),
5712 }
5713 }
5714 }
5715 #[derive(Clone, Debug)]
5716 #[doc = " Packet was sent by a connection"]
5717 pub struct PacketSent {
5718 pub packet_header: PacketHeader,
5719 pub packet_len: usize,
5720 }
5721 impl IntoEvent<api::PacketSent> for PacketSent {
5722 #[inline]
5723 fn into_event(self) -> api::PacketSent {
5724 let PacketSent {
5725 packet_header,
5726 packet_len,
5727 } = self;
5728 api::PacketSent {
5729 packet_header: packet_header.into_event(),
5730 packet_len: packet_len.into_event(),
5731 }
5732 }
5733 }
5734 #[derive(Clone, Debug)]
5735 #[doc = " Packet was received by a connection"]
5736 pub struct PacketReceived {
5737 pub packet_header: PacketHeader,
5738 }
5739 impl IntoEvent<api::PacketReceived> for PacketReceived {
5740 #[inline]
5741 fn into_event(self) -> api::PacketReceived {
5742 let PacketReceived { packet_header } = self;
5743 api::PacketReceived {
5744 packet_header: packet_header.into_event(),
5745 }
5746 }
5747 }
5748 #[derive(Clone, Debug)]
5749 #[doc = " Active path was updated"]
5750 pub struct ActivePathUpdated<'a> {
5751 pub previous: Path<'a>,
5752 pub active: Path<'a>,
5753 }
5754 impl<'a> IntoEvent<api::ActivePathUpdated<'a>> for ActivePathUpdated<'a> {
5755 #[inline]
5756 fn into_event(self) -> api::ActivePathUpdated<'a> {
5757 let ActivePathUpdated { previous, active } = self;
5758 api::ActivePathUpdated {
5759 previous: previous.into_event(),
5760 active: active.into_event(),
5761 }
5762 }
5763 }
5764 #[derive(Clone, Debug)]
5765 #[doc = " A new path was created"]
5766 pub struct PathCreated<'a> {
5767 pub active: Path<'a>,
5768 pub new: Path<'a>,
5769 }
5770 impl<'a> IntoEvent<api::PathCreated<'a>> for PathCreated<'a> {
5771 #[inline]
5772 fn into_event(self) -> api::PathCreated<'a> {
5773 let PathCreated { active, new } = self;
5774 api::PathCreated {
5775 active: active.into_event(),
5776 new: new.into_event(),
5777 }
5778 }
5779 }
5780 #[derive(Clone, Debug)]
5781 #[doc = " Frame was sent"]
5782 pub struct FrameSent {
5783 pub packet_header: PacketHeader,
5784 pub path_id: u64,
5785 pub frame: Frame,
5786 }
5787 impl IntoEvent<api::FrameSent> for FrameSent {
5788 #[inline]
5789 fn into_event(self) -> api::FrameSent {
5790 let FrameSent {
5791 packet_header,
5792 path_id,
5793 frame,
5794 } = self;
5795 api::FrameSent {
5796 packet_header: packet_header.into_event(),
5797 path_id: path_id.into_event(),
5798 frame: frame.into_event(),
5799 }
5800 }
5801 }
5802 #[derive(Clone, Debug)]
5803 #[doc = " Frame was received"]
5804 pub struct FrameReceived<'a> {
5805 pub packet_header: PacketHeader,
5806 pub path: Path<'a>,
5807 pub frame: Frame,
5808 }
5809 impl<'a> IntoEvent<api::FrameReceived<'a>> for FrameReceived<'a> {
5810 #[inline]
5811 fn into_event(self) -> api::FrameReceived<'a> {
5812 let FrameReceived {
5813 packet_header,
5814 path,
5815 frame,
5816 } = self;
5817 api::FrameReceived {
5818 packet_header: packet_header.into_event(),
5819 path: path.into_event(),
5820 frame: frame.into_event(),
5821 }
5822 }
5823 }
5824 #[derive(Clone, Debug)]
5825 #[doc = " A `CONNECTION_CLOSE` frame was received"]
5826 #[doc = ""]
5827 #[doc = " This event includes additional details from the frame, particularly the"]
5828 #[doc = " reason (if provided) the peer closed the connection"]
5829 pub struct ConnectionCloseFrameReceived<'a> {
5830 pub packet_header: PacketHeader,
5831 pub path: Path<'a>,
5832 pub frame: ConnectionCloseFrame<'a>,
5833 }
5834 impl<'a> IntoEvent<api::ConnectionCloseFrameReceived<'a>> for ConnectionCloseFrameReceived<'a> {
5835 #[inline]
5836 fn into_event(self) -> api::ConnectionCloseFrameReceived<'a> {
5837 let ConnectionCloseFrameReceived {
5838 packet_header,
5839 path,
5840 frame,
5841 } = self;
5842 api::ConnectionCloseFrameReceived {
5843 packet_header: packet_header.into_event(),
5844 path: path.into_event(),
5845 frame: frame.into_event(),
5846 }
5847 }
5848 }
5849 #[derive(Clone, Debug)]
5850 #[doc = " Packet was lost"]
5851 pub struct PacketLost<'a> {
5852 pub packet_header: PacketHeader,
5853 pub path: Path<'a>,
5854 pub bytes_lost: u16,
5855 pub is_mtu_probe: bool,
5856 }
5857 impl<'a> IntoEvent<api::PacketLost<'a>> for PacketLost<'a> {
5858 #[inline]
5859 fn into_event(self) -> api::PacketLost<'a> {
5860 let PacketLost {
5861 packet_header,
5862 path,
5863 bytes_lost,
5864 is_mtu_probe,
5865 } = self;
5866 api::PacketLost {
5867 packet_header: packet_header.into_event(),
5868 path: path.into_event(),
5869 bytes_lost: bytes_lost.into_event(),
5870 is_mtu_probe: is_mtu_probe.into_event(),
5871 }
5872 }
5873 }
5874 #[derive(Clone, Debug)]
5875 #[doc = " Recovery metrics updated"]
5876 pub struct RecoveryMetrics<'a> {
5877 pub path: Path<'a>,
5878 pub min_rtt: Duration,
5879 pub smoothed_rtt: Duration,
5880 pub latest_rtt: Duration,
5881 pub rtt_variance: Duration,
5882 pub max_ack_delay: Duration,
5883 pub pto_count: u32,
5884 pub congestion_window: u32,
5885 pub bytes_in_flight: u32,
5886 pub congestion_limited: bool,
5887 }
5888 impl<'a> IntoEvent<api::RecoveryMetrics<'a>> for RecoveryMetrics<'a> {
5889 #[inline]
5890 fn into_event(self) -> api::RecoveryMetrics<'a> {
5891 let RecoveryMetrics {
5892 path,
5893 min_rtt,
5894 smoothed_rtt,
5895 latest_rtt,
5896 rtt_variance,
5897 max_ack_delay,
5898 pto_count,
5899 congestion_window,
5900 bytes_in_flight,
5901 congestion_limited,
5902 } = self;
5903 api::RecoveryMetrics {
5904 path: path.into_event(),
5905 min_rtt: min_rtt.into_event(),
5906 smoothed_rtt: smoothed_rtt.into_event(),
5907 latest_rtt: latest_rtt.into_event(),
5908 rtt_variance: rtt_variance.into_event(),
5909 max_ack_delay: max_ack_delay.into_event(),
5910 pto_count: pto_count.into_event(),
5911 congestion_window: congestion_window.into_event(),
5912 bytes_in_flight: bytes_in_flight.into_event(),
5913 congestion_limited: congestion_limited.into_event(),
5914 }
5915 }
5916 }
5917 #[derive(Clone, Debug)]
5918 #[doc = " Congestion (ECN or packet loss) has occurred"]
5919 pub struct Congestion<'a> {
5920 pub path: Path<'a>,
5921 pub source: CongestionSource,
5922 }
5923 impl<'a> IntoEvent<api::Congestion<'a>> for Congestion<'a> {
5924 #[inline]
5925 fn into_event(self) -> api::Congestion<'a> {
5926 let Congestion { path, source } = self;
5927 api::Congestion {
5928 path: path.into_event(),
5929 source: source.into_event(),
5930 }
5931 }
5932 }
5933 #[derive(Clone, Debug)]
5934 #[doc = " Events related to ACK processing"]
5935 pub struct AckProcessed<'a> {
5936 pub action: AckAction,
5937 pub path: Path<'a>,
5938 }
5939 #[allow(deprecated)]
5940 impl<'a> IntoEvent<api::AckProcessed<'a>> for AckProcessed<'a> {
5941 #[inline]
5942 fn into_event(self) -> api::AckProcessed<'a> {
5943 let AckProcessed { action, path } = self;
5944 api::AckProcessed {
5945 action: action.into_event(),
5946 path: path.into_event(),
5947 }
5948 }
5949 }
5950 #[derive(Clone, Debug)]
5951 #[doc = " Ack range for received packets was dropped due to space constraints"]
5952 #[doc = ""]
5953 #[doc = " For the purpose of processing Acks, RX packet numbers are stored as"]
5954 #[doc = " packet_number ranges in an IntervalSet; only lower and upper bounds"]
5955 #[doc = " are stored instead of individual packet_numbers. Ranges are merged"]
5956 #[doc = " when possible so only disjointed ranges are stored."]
5957 #[doc = ""]
5958 #[doc = " When at `capacity`, the lowest packet_number range is dropped."]
5959 pub struct RxAckRangeDropped<'a> {
5960 pub path: Path<'a>,
5961 #[doc = " The packet number range which was dropped"]
5962 pub packet_number_range: core::ops::RangeInclusive<u64>,
5963 #[doc = " The number of disjoint ranges the IntervalSet can store"]
5964 pub capacity: usize,
5965 #[doc = " The store packet_number range in the IntervalSet"]
5966 pub stored_range: core::ops::RangeInclusive<u64>,
5967 }
5968 impl<'a> IntoEvent<api::RxAckRangeDropped<'a>> for RxAckRangeDropped<'a> {
5969 #[inline]
5970 fn into_event(self) -> api::RxAckRangeDropped<'a> {
5971 let RxAckRangeDropped {
5972 path,
5973 packet_number_range,
5974 capacity,
5975 stored_range,
5976 } = self;
5977 api::RxAckRangeDropped {
5978 path: path.into_event(),
5979 packet_number_range: packet_number_range.into_event(),
5980 capacity: capacity.into_event(),
5981 stored_range: stored_range.into_event(),
5982 }
5983 }
5984 }
5985 #[derive(Clone, Debug)]
5986 #[doc = " ACK range was received"]
5987 pub struct AckRangeReceived<'a> {
5988 pub packet_header: PacketHeader,
5989 pub path: Path<'a>,
5990 pub ack_range: RangeInclusive<u64>,
5991 }
5992 impl<'a> IntoEvent<api::AckRangeReceived<'a>> for AckRangeReceived<'a> {
5993 #[inline]
5994 fn into_event(self) -> api::AckRangeReceived<'a> {
5995 let AckRangeReceived {
5996 packet_header,
5997 path,
5998 ack_range,
5999 } = self;
6000 api::AckRangeReceived {
6001 packet_header: packet_header.into_event(),
6002 path: path.into_event(),
6003 ack_range: ack_range.into_event(),
6004 }
6005 }
6006 }
6007 #[derive(Clone, Debug)]
6008 #[doc = " ACK range was sent"]
6009 pub struct AckRangeSent {
6010 pub packet_header: PacketHeader,
6011 pub path_id: u64,
6012 pub ack_range: RangeInclusive<u64>,
6013 }
6014 impl IntoEvent<api::AckRangeSent> for AckRangeSent {
6015 #[inline]
6016 fn into_event(self) -> api::AckRangeSent {
6017 let AckRangeSent {
6018 packet_header,
6019 path_id,
6020 ack_range,
6021 } = self;
6022 api::AckRangeSent {
6023 packet_header: packet_header.into_event(),
6024 path_id: path_id.into_event(),
6025 ack_range: ack_range.into_event(),
6026 }
6027 }
6028 }
6029 #[derive(Clone, Debug)]
6030 #[doc = " Packet was dropped with the given reason"]
6031 pub struct PacketDropped<'a> {
6032 pub reason: PacketDropReason<'a>,
6033 }
6034 impl<'a> IntoEvent<api::PacketDropped<'a>> for PacketDropped<'a> {
6035 #[inline]
6036 fn into_event(self) -> api::PacketDropped<'a> {
6037 let PacketDropped { reason } = self;
6038 api::PacketDropped {
6039 reason: reason.into_event(),
6040 }
6041 }
6042 }
6043 #[derive(Clone, Debug)]
6044 #[doc = " Crypto key updated"]
6045 pub struct KeyUpdate {
6046 pub key_type: KeyType,
6047 pub cipher_suite: CipherSuite,
6048 }
6049 impl IntoEvent<api::KeyUpdate> for KeyUpdate {
6050 #[inline]
6051 fn into_event(self) -> api::KeyUpdate {
6052 let KeyUpdate {
6053 key_type,
6054 cipher_suite,
6055 } = self;
6056 api::KeyUpdate {
6057 key_type: key_type.into_event(),
6058 cipher_suite: cipher_suite.into_event(),
6059 }
6060 }
6061 }
6062 #[derive(Clone, Debug)]
6063 pub struct KeySpaceDiscarded {
6064 pub space: KeySpace,
6065 }
6066 impl IntoEvent<api::KeySpaceDiscarded> for KeySpaceDiscarded {
6067 #[inline]
6068 fn into_event(self) -> api::KeySpaceDiscarded {
6069 let KeySpaceDiscarded { space } = self;
6070 api::KeySpaceDiscarded {
6071 space: space.into_event(),
6072 }
6073 }
6074 }
6075 #[derive(Clone, Debug)]
6076 #[doc = " Connection started"]
6077 pub struct ConnectionStarted<'a> {
6078 pub path: Path<'a>,
6079 }
6080 impl<'a> IntoEvent<api::ConnectionStarted<'a>> for ConnectionStarted<'a> {
6081 #[inline]
6082 fn into_event(self) -> api::ConnectionStarted<'a> {
6083 let ConnectionStarted { path } = self;
6084 api::ConnectionStarted {
6085 path: path.into_event(),
6086 }
6087 }
6088 }
6089 #[derive(Clone, Debug)]
6090 #[doc = " Duplicate packet received"]
6091 pub struct DuplicatePacket<'a> {
6092 pub packet_header: PacketHeader,
6093 pub path: Path<'a>,
6094 pub error: DuplicatePacketError,
6095 }
6096 impl<'a> IntoEvent<api::DuplicatePacket<'a>> for DuplicatePacket<'a> {
6097 #[inline]
6098 fn into_event(self) -> api::DuplicatePacket<'a> {
6099 let DuplicatePacket {
6100 packet_header,
6101 path,
6102 error,
6103 } = self;
6104 api::DuplicatePacket {
6105 packet_header: packet_header.into_event(),
6106 path: path.into_event(),
6107 error: error.into_event(),
6108 }
6109 }
6110 }
6111 #[derive(Clone, Debug)]
6112 #[doc = " Transport parameters received by connection"]
6113 pub struct TransportParametersReceived<'a> {
6114 pub transport_parameters: TransportParameters<'a>,
6115 }
6116 impl<'a> IntoEvent<api::TransportParametersReceived<'a>> for TransportParametersReceived<'a> {
6117 #[inline]
6118 fn into_event(self) -> api::TransportParametersReceived<'a> {
6119 let TransportParametersReceived {
6120 transport_parameters,
6121 } = self;
6122 api::TransportParametersReceived {
6123 transport_parameters: transport_parameters.into_event(),
6124 }
6125 }
6126 }
6127 #[derive(Clone, Debug)]
6128 #[doc = " Datagram sent by a connection"]
6129 pub struct DatagramSent {
6130 pub len: u16,
6131 #[doc = " The GSO offset at which this datagram was written"]
6132 #[doc = ""]
6133 #[doc = " If this value is greater than 0, it indicates that this datagram has been sent with other"]
6134 #[doc = " segments in a single buffer."]
6135 #[doc = ""]
6136 #[doc = " See the [Linux kernel documentation](https://www.kernel.org/doc/html/latest/networking/segmentation-offloads.html#generic-segmentation-offload) for more details."]
6137 pub gso_offset: usize,
6138 }
6139 impl IntoEvent<api::DatagramSent> for DatagramSent {
6140 #[inline]
6141 fn into_event(self) -> api::DatagramSent {
6142 let DatagramSent { len, gso_offset } = self;
6143 api::DatagramSent {
6144 len: len.into_event(),
6145 gso_offset: gso_offset.into_event(),
6146 }
6147 }
6148 }
6149 #[derive(Clone, Debug)]
6150 #[doc = " Datagram received by a connection"]
6151 pub struct DatagramReceived {
6152 pub len: u16,
6153 }
6154 impl IntoEvent<api::DatagramReceived> for DatagramReceived {
6155 #[inline]
6156 fn into_event(self) -> api::DatagramReceived {
6157 let DatagramReceived { len } = self;
6158 api::DatagramReceived {
6159 len: len.into_event(),
6160 }
6161 }
6162 }
6163 #[derive(Clone, Debug)]
6164 #[doc = " Datagram dropped by a connection"]
6165 pub struct DatagramDropped<'a> {
6166 pub local_addr: SocketAddress<'a>,
6167 pub remote_addr: SocketAddress<'a>,
6168 pub destination_cid: ConnectionId<'a>,
6169 pub source_cid: Option<ConnectionId<'a>>,
6170 pub len: u16,
6171 pub reason: DatagramDropReason,
6172 }
6173 impl<'a> IntoEvent<api::DatagramDropped<'a>> for DatagramDropped<'a> {
6174 #[inline]
6175 fn into_event(self) -> api::DatagramDropped<'a> {
6176 let DatagramDropped {
6177 local_addr,
6178 remote_addr,
6179 destination_cid,
6180 source_cid,
6181 len,
6182 reason,
6183 } = self;
6184 api::DatagramDropped {
6185 local_addr: local_addr.into_event(),
6186 remote_addr: remote_addr.into_event(),
6187 destination_cid: destination_cid.into_event(),
6188 source_cid: source_cid.into_event(),
6189 len: len.into_event(),
6190 reason: reason.into_event(),
6191 }
6192 }
6193 }
6194 #[derive(Clone, Debug)]
6195 #[doc = " The remote address was changed before the handshake was complete"]
6196 pub struct HandshakeRemoteAddressChangeObserved<'a> {
6197 pub local_addr: SocketAddress<'a>,
6198 #[doc = " The newly observed remote address"]
6199 pub remote_addr: SocketAddress<'a>,
6200 #[doc = " The remote address established from the initial packet"]
6201 pub initial_remote_addr: SocketAddress<'a>,
6202 }
6203 impl<'a> IntoEvent<api::HandshakeRemoteAddressChangeObserved<'a>>
6204 for HandshakeRemoteAddressChangeObserved<'a>
6205 {
6206 #[inline]
6207 fn into_event(self) -> api::HandshakeRemoteAddressChangeObserved<'a> {
6208 let HandshakeRemoteAddressChangeObserved {
6209 local_addr,
6210 remote_addr,
6211 initial_remote_addr,
6212 } = self;
6213 api::HandshakeRemoteAddressChangeObserved {
6214 local_addr: local_addr.into_event(),
6215 remote_addr: remote_addr.into_event(),
6216 initial_remote_addr: initial_remote_addr.into_event(),
6217 }
6218 }
6219 }
6220 #[derive(Clone, Debug)]
6221 #[doc = " ConnectionId updated"]
6222 pub struct ConnectionIdUpdated<'a> {
6223 pub path_id: u64,
6224 #[doc = " The endpoint that updated its connection id"]
6225 pub cid_consumer: crate::endpoint::Location,
6226 pub previous: ConnectionId<'a>,
6227 pub current: ConnectionId<'a>,
6228 }
6229 impl<'a> IntoEvent<api::ConnectionIdUpdated<'a>> for ConnectionIdUpdated<'a> {
6230 #[inline]
6231 fn into_event(self) -> api::ConnectionIdUpdated<'a> {
6232 let ConnectionIdUpdated {
6233 path_id,
6234 cid_consumer,
6235 previous,
6236 current,
6237 } = self;
6238 api::ConnectionIdUpdated {
6239 path_id: path_id.into_event(),
6240 cid_consumer: cid_consumer.into_event(),
6241 previous: previous.into_event(),
6242 current: current.into_event(),
6243 }
6244 }
6245 }
6246 #[derive(Clone, Debug)]
6247 pub struct EcnStateChanged<'a> {
6248 pub path: Path<'a>,
6249 pub state: EcnState,
6250 }
6251 impl<'a> IntoEvent<api::EcnStateChanged<'a>> for EcnStateChanged<'a> {
6252 #[inline]
6253 fn into_event(self) -> api::EcnStateChanged<'a> {
6254 let EcnStateChanged { path, state } = self;
6255 api::EcnStateChanged {
6256 path: path.into_event(),
6257 state: state.into_event(),
6258 }
6259 }
6260 }
6261 #[derive(Clone, Debug)]
6262 pub struct ConnectionMigrationDenied {
6263 pub reason: MigrationDenyReason,
6264 }
6265 impl IntoEvent<api::ConnectionMigrationDenied> for ConnectionMigrationDenied {
6266 #[inline]
6267 fn into_event(self) -> api::ConnectionMigrationDenied {
6268 let ConnectionMigrationDenied { reason } = self;
6269 api::ConnectionMigrationDenied {
6270 reason: reason.into_event(),
6271 }
6272 }
6273 }
6274 #[derive(Clone, Debug)]
6275 pub struct HandshakeStatusUpdated {
6276 pub status: HandshakeStatus,
6277 }
6278 impl IntoEvent<api::HandshakeStatusUpdated> for HandshakeStatusUpdated {
6279 #[inline]
6280 fn into_event(self) -> api::HandshakeStatusUpdated {
6281 let HandshakeStatusUpdated { status } = self;
6282 api::HandshakeStatusUpdated {
6283 status: status.into_event(),
6284 }
6285 }
6286 }
6287 #[derive(Clone, Debug)]
6288 pub struct TlsExporterReady<'a> {
6289 pub session: crate::event::TlsSession<'a>,
6290 }
6291 impl<'a> IntoEvent<api::TlsExporterReady<'a>> for TlsExporterReady<'a> {
6292 #[inline]
6293 fn into_event(self) -> api::TlsExporterReady<'a> {
6294 let TlsExporterReady { session } = self;
6295 api::TlsExporterReady {
6296 session: session.into_event(),
6297 }
6298 }
6299 }
6300 #[derive(Clone, Debug)]
6301 pub struct TlsHandshakeFailed<'a> {
6302 pub session: crate::event::TlsSession<'a>,
6303 }
6304 impl<'a> IntoEvent<api::TlsHandshakeFailed<'a>> for TlsHandshakeFailed<'a> {
6305 #[inline]
6306 fn into_event(self) -> api::TlsHandshakeFailed<'a> {
6307 let TlsHandshakeFailed { session } = self;
6308 api::TlsHandshakeFailed {
6309 session: session.into_event(),
6310 }
6311 }
6312 }
6313 #[derive(Clone, Debug)]
6314 #[doc = " Path challenge updated"]
6315 pub struct PathChallengeUpdated<'a> {
6316 pub path_challenge_status: PathChallengeStatus,
6317 pub path: Path<'a>,
6318 pub challenge_data: &'a [u8],
6319 }
6320 impl<'a> IntoEvent<api::PathChallengeUpdated<'a>> for PathChallengeUpdated<'a> {
6321 #[inline]
6322 fn into_event(self) -> api::PathChallengeUpdated<'a> {
6323 let PathChallengeUpdated {
6324 path_challenge_status,
6325 path,
6326 challenge_data,
6327 } = self;
6328 api::PathChallengeUpdated {
6329 path_challenge_status: path_challenge_status.into_event(),
6330 path: path.into_event(),
6331 challenge_data: challenge_data.into_event(),
6332 }
6333 }
6334 }
6335 #[derive(Clone, Debug)]
6336 pub struct TlsClientHello<'a> {
6337 pub payload: &'a [&'a [u8]],
6338 }
6339 impl<'a> IntoEvent<api::TlsClientHello<'a>> for TlsClientHello<'a> {
6340 #[inline]
6341 fn into_event(self) -> api::TlsClientHello<'a> {
6342 let TlsClientHello { payload } = self;
6343 api::TlsClientHello {
6344 payload: payload.into_event(),
6345 }
6346 }
6347 }
6348 #[derive(Clone, Debug)]
6349 pub struct TlsServerHello<'a> {
6350 pub payload: &'a [&'a [u8]],
6351 }
6352 impl<'a> IntoEvent<api::TlsServerHello<'a>> for TlsServerHello<'a> {
6353 #[inline]
6354 fn into_event(self) -> api::TlsServerHello<'a> {
6355 let TlsServerHello { payload } = self;
6356 api::TlsServerHello {
6357 payload: payload.into_event(),
6358 }
6359 }
6360 }
6361 #[derive(Clone, Debug)]
6362 pub struct RxStreamProgress {
6363 pub bytes: usize,
6364 }
6365 impl IntoEvent<api::RxStreamProgress> for RxStreamProgress {
6366 #[inline]
6367 fn into_event(self) -> api::RxStreamProgress {
6368 let RxStreamProgress { bytes } = self;
6369 api::RxStreamProgress {
6370 bytes: bytes.into_event(),
6371 }
6372 }
6373 }
6374 #[derive(Clone, Debug)]
6375 pub struct TxStreamProgress {
6376 pub bytes: usize,
6377 }
6378 impl IntoEvent<api::TxStreamProgress> for TxStreamProgress {
6379 #[inline]
6380 fn into_event(self) -> api::TxStreamProgress {
6381 let TxStreamProgress { bytes } = self;
6382 api::TxStreamProgress {
6383 bytes: bytes.into_event(),
6384 }
6385 }
6386 }
6387 #[derive(Clone, Debug)]
6388 pub struct KeepAliveTimerExpired {
6389 pub timeout: Duration,
6390 }
6391 impl IntoEvent<api::KeepAliveTimerExpired> for KeepAliveTimerExpired {
6392 #[inline]
6393 fn into_event(self) -> api::KeepAliveTimerExpired {
6394 let KeepAliveTimerExpired { timeout } = self;
6395 api::KeepAliveTimerExpired {
6396 timeout: timeout.into_event(),
6397 }
6398 }
6399 }
6400 #[derive(Clone, Debug)]
6401 #[doc = " The maximum transmission unit (MTU) and/or MTU probing status for the path has changed"]
6402 pub struct MtuUpdated {
6403 pub path_id: u64,
6404 #[doc = " The maximum QUIC datagram size, not including UDP and IP headers"]
6405 pub mtu: u16,
6406 pub cause: MtuUpdatedCause,
6407 #[doc = " The search for the maximum MTU has completed for now"]
6408 pub search_complete: bool,
6409 }
6410 impl IntoEvent<api::MtuUpdated> for MtuUpdated {
6411 #[inline]
6412 fn into_event(self) -> api::MtuUpdated {
6413 let MtuUpdated {
6414 path_id,
6415 mtu,
6416 cause,
6417 search_complete,
6418 } = self;
6419 api::MtuUpdated {
6420 path_id: path_id.into_event(),
6421 mtu: mtu.into_event(),
6422 cause: cause.into_event(),
6423 search_complete: search_complete.into_event(),
6424 }
6425 }
6426 }
6427 #[derive(Clone, Debug)]
6428 #[doc = " The slow start congestion controller state has been exited"]
6429 pub struct SlowStartExited {
6430 pub path_id: u64,
6431 pub cause: SlowStartExitCause,
6432 pub congestion_window: u32,
6433 }
6434 impl IntoEvent<api::SlowStartExited> for SlowStartExited {
6435 #[inline]
6436 fn into_event(self) -> api::SlowStartExited {
6437 let SlowStartExited {
6438 path_id,
6439 cause,
6440 congestion_window,
6441 } = self;
6442 api::SlowStartExited {
6443 path_id: path_id.into_event(),
6444 cause: cause.into_event(),
6445 congestion_window: congestion_window.into_event(),
6446 }
6447 }
6448 }
6449 #[derive(Clone, Debug)]
6450 #[doc = " A new delivery rate sample has been generated"]
6451 #[doc = " Note: This event is only recorded for congestion controllers that support"]
6452 #[doc = " bandwidth estimates, such as BBR"]
6453 pub struct DeliveryRateSampled {
6454 pub path_id: u64,
6455 pub rate_sample: RateSample,
6456 }
6457 impl IntoEvent<api::DeliveryRateSampled> for DeliveryRateSampled {
6458 #[inline]
6459 fn into_event(self) -> api::DeliveryRateSampled {
6460 let DeliveryRateSampled {
6461 path_id,
6462 rate_sample,
6463 } = self;
6464 api::DeliveryRateSampled {
6465 path_id: path_id.into_event(),
6466 rate_sample: rate_sample.into_event(),
6467 }
6468 }
6469 }
6470 #[derive(Clone, Debug)]
6471 #[doc = " The pacing rate has been updated"]
6472 pub struct PacingRateUpdated {
6473 pub path_id: u64,
6474 pub bytes_per_second: u64,
6475 pub burst_size: u32,
6476 pub pacing_gain: f32,
6477 }
6478 impl IntoEvent<api::PacingRateUpdated> for PacingRateUpdated {
6479 #[inline]
6480 fn into_event(self) -> api::PacingRateUpdated {
6481 let PacingRateUpdated {
6482 path_id,
6483 bytes_per_second,
6484 burst_size,
6485 pacing_gain,
6486 } = self;
6487 api::PacingRateUpdated {
6488 path_id: path_id.into_event(),
6489 bytes_per_second: bytes_per_second.into_event(),
6490 burst_size: burst_size.into_event(),
6491 pacing_gain: pacing_gain.into_event(),
6492 }
6493 }
6494 }
6495 #[derive(Clone, Debug)]
6496 #[doc = " The BBR state has changed"]
6497 pub struct BbrStateChanged {
6498 pub path_id: u64,
6499 pub state: BbrState,
6500 }
6501 impl IntoEvent<api::BbrStateChanged> for BbrStateChanged {
6502 #[inline]
6503 fn into_event(self) -> api::BbrStateChanged {
6504 let BbrStateChanged { path_id, state } = self;
6505 api::BbrStateChanged {
6506 path_id: path_id.into_event(),
6507 state: state.into_event(),
6508 }
6509 }
6510 }
6511 #[derive(Clone, Debug)]
6512 #[doc = " The DC state has changed"]
6513 pub struct DcStateChanged {
6514 pub state: DcState,
6515 }
6516 impl IntoEvent<api::DcStateChanged> for DcStateChanged {
6517 #[inline]
6518 fn into_event(self) -> api::DcStateChanged {
6519 let DcStateChanged { state } = self;
6520 api::DcStateChanged {
6521 state: state.into_event(),
6522 }
6523 }
6524 }
6525 #[derive(Clone, Debug)]
6526 #[doc = " The DC path has been created"]
6527 pub struct DcPathCreated<'a> {
6528 #[doc = " This is the dc::Path struct, it's just type-erased. But if an event subscriber knows the"]
6529 #[doc = " type they can downcast."]
6530 pub path: &'a (dyn core::any::Any + Send + 'static),
6531 }
6532 impl<'a> IntoEvent<api::DcPathCreated<'a>> for DcPathCreated<'a> {
6533 #[inline]
6534 fn into_event(self) -> api::DcPathCreated<'a> {
6535 let DcPathCreated { path } = self;
6536 api::DcPathCreated {
6537 path: path.into_event(),
6538 }
6539 }
6540 }
6541 #[derive(Clone, Debug)]
6542 #[doc = " Connection closed"]
6543 pub struct ConnectionClosed {
6544 pub error: crate::connection::Error,
6545 }
6546 impl IntoEvent<api::ConnectionClosed> for ConnectionClosed {
6547 #[inline]
6548 fn into_event(self) -> api::ConnectionClosed {
6549 let ConnectionClosed { error } = self;
6550 api::ConnectionClosed {
6551 error: error.into_event(),
6552 }
6553 }
6554 }
6555 #[derive(Clone, Debug)]
6556 #[doc = " QUIC version"]
6557 pub struct VersionInformation<'a> {
6558 pub server_versions: &'a [u32],
6559 pub client_versions: &'a [u32],
6560 pub chosen_version: Option<u32>,
6561 }
6562 impl<'a> IntoEvent<api::VersionInformation<'a>> for VersionInformation<'a> {
6563 #[inline]
6564 fn into_event(self) -> api::VersionInformation<'a> {
6565 let VersionInformation {
6566 server_versions,
6567 client_versions,
6568 chosen_version,
6569 } = self;
6570 api::VersionInformation {
6571 server_versions: server_versions.into_event(),
6572 client_versions: client_versions.into_event(),
6573 chosen_version: chosen_version.into_event(),
6574 }
6575 }
6576 }
6577 #[derive(Clone, Debug)]
6578 #[doc = " Packet was sent by the endpoint"]
6579 pub struct EndpointPacketSent {
6580 pub packet_header: PacketHeader,
6581 }
6582 impl IntoEvent<api::EndpointPacketSent> for EndpointPacketSent {
6583 #[inline]
6584 fn into_event(self) -> api::EndpointPacketSent {
6585 let EndpointPacketSent { packet_header } = self;
6586 api::EndpointPacketSent {
6587 packet_header: packet_header.into_event(),
6588 }
6589 }
6590 }
6591 #[derive(Clone, Debug)]
6592 #[doc = " Packet was received by the endpoint"]
6593 pub struct EndpointPacketReceived {
6594 pub packet_header: PacketHeader,
6595 }
6596 impl IntoEvent<api::EndpointPacketReceived> for EndpointPacketReceived {
6597 #[inline]
6598 fn into_event(self) -> api::EndpointPacketReceived {
6599 let EndpointPacketReceived { packet_header } = self;
6600 api::EndpointPacketReceived {
6601 packet_header: packet_header.into_event(),
6602 }
6603 }
6604 }
6605 #[derive(Clone, Debug)]
6606 #[doc = " Datagram sent by the endpoint"]
6607 pub struct EndpointDatagramSent {
6608 pub len: u16,
6609 #[doc = " The GSO offset at which this datagram was written"]
6610 #[doc = ""]
6611 #[doc = " If this value is greater than 0, it indicates that this datagram has been sent with other"]
6612 #[doc = " segments in a single buffer."]
6613 #[doc = ""]
6614 #[doc = " See the [Linux kernel documentation](https://www.kernel.org/doc/html/latest/networking/segmentation-offloads.html#generic-segmentation-offload) for more details."]
6615 pub gso_offset: usize,
6616 }
6617 impl IntoEvent<api::EndpointDatagramSent> for EndpointDatagramSent {
6618 #[inline]
6619 fn into_event(self) -> api::EndpointDatagramSent {
6620 let EndpointDatagramSent { len, gso_offset } = self;
6621 api::EndpointDatagramSent {
6622 len: len.into_event(),
6623 gso_offset: gso_offset.into_event(),
6624 }
6625 }
6626 }
6627 #[derive(Clone, Debug)]
6628 #[doc = " Datagram received by the endpoint"]
6629 pub struct EndpointDatagramReceived {
6630 pub len: u16,
6631 }
6632 impl IntoEvent<api::EndpointDatagramReceived> for EndpointDatagramReceived {
6633 #[inline]
6634 fn into_event(self) -> api::EndpointDatagramReceived {
6635 let EndpointDatagramReceived { len } = self;
6636 api::EndpointDatagramReceived {
6637 len: len.into_event(),
6638 }
6639 }
6640 }
6641 #[derive(Clone, Debug)]
6642 #[doc = " Datagram dropped by the endpoint"]
6643 pub struct EndpointDatagramDropped {
6644 pub len: u16,
6645 pub reason: DatagramDropReason,
6646 }
6647 impl IntoEvent<api::EndpointDatagramDropped> for EndpointDatagramDropped {
6648 #[inline]
6649 fn into_event(self) -> api::EndpointDatagramDropped {
6650 let EndpointDatagramDropped { len, reason } = self;
6651 api::EndpointDatagramDropped {
6652 len: len.into_event(),
6653 reason: reason.into_event(),
6654 }
6655 }
6656 }
6657 #[derive(Clone, Debug)]
6658 pub struct EndpointConnectionAttemptFailed {
6659 pub error: crate::connection::Error,
6660 }
6661 impl IntoEvent<api::EndpointConnectionAttemptFailed> for EndpointConnectionAttemptFailed {
6662 #[inline]
6663 fn into_event(self) -> api::EndpointConnectionAttemptFailed {
6664 let EndpointConnectionAttemptFailed { error } = self;
6665 api::EndpointConnectionAttemptFailed {
6666 error: error.into_event(),
6667 }
6668 }
6669 }
6670 #[derive(Clone, Debug)]
6671 pub struct EndpointConnectionAttemptDeduplicated {
6672 #[doc = " The internal connection ID this deduplicated with."]
6673 pub connection_id: u64,
6674 pub already_open: bool,
6675 }
6676 impl IntoEvent<api::EndpointConnectionAttemptDeduplicated>
6677 for EndpointConnectionAttemptDeduplicated
6678 {
6679 #[inline]
6680 fn into_event(self) -> api::EndpointConnectionAttemptDeduplicated {
6681 let EndpointConnectionAttemptDeduplicated {
6682 connection_id,
6683 already_open,
6684 } = self;
6685 api::EndpointConnectionAttemptDeduplicated {
6686 connection_id: connection_id.into_event(),
6687 already_open: already_open.into_event(),
6688 }
6689 }
6690 }
6691 #[derive(Clone, Debug)]
6692 #[doc = " Emitted when the platform sends at least one packet"]
6693 pub struct PlatformTx {
6694 #[doc = " The number of packets sent"]
6695 pub count: usize,
6696 #[doc = " The number of syscalls performed"]
6697 pub syscalls: usize,
6698 #[doc = " The number of syscalls that got blocked"]
6699 pub blocked_syscalls: usize,
6700 #[doc = " The total number of errors encountered since the last event"]
6701 pub total_errors: usize,
6702 #[doc = " The number of specific error codes dropped"]
6703 #[doc = ""]
6704 #[doc = " This can happen when a burst of errors exceeds the capacity of the recorder"]
6705 pub dropped_errors: usize,
6706 }
6707 impl IntoEvent<api::PlatformTx> for PlatformTx {
6708 #[inline]
6709 fn into_event(self) -> api::PlatformTx {
6710 let PlatformTx {
6711 count,
6712 syscalls,
6713 blocked_syscalls,
6714 total_errors,
6715 dropped_errors,
6716 } = self;
6717 api::PlatformTx {
6718 count: count.into_event(),
6719 syscalls: syscalls.into_event(),
6720 blocked_syscalls: blocked_syscalls.into_event(),
6721 total_errors: total_errors.into_event(),
6722 dropped_errors: dropped_errors.into_event(),
6723 }
6724 }
6725 }
6726 #[derive(Clone, Debug)]
6727 #[doc = " Emitted when the platform returns an error while sending datagrams"]
6728 pub struct PlatformTxError {
6729 #[doc = " The error code returned by the platform"]
6730 pub errno: i32,
6731 }
6732 impl IntoEvent<api::PlatformTxError> for PlatformTxError {
6733 #[inline]
6734 fn into_event(self) -> api::PlatformTxError {
6735 let PlatformTxError { errno } = self;
6736 api::PlatformTxError {
6737 errno: errno.into_event(),
6738 }
6739 }
6740 }
6741 #[derive(Clone, Debug)]
6742 #[doc = " Emitted when the platform receives at least one packet"]
6743 pub struct PlatformRx {
6744 #[doc = " The number of packets received"]
6745 pub count: usize,
6746 #[doc = " The number of syscalls performed"]
6747 pub syscalls: usize,
6748 #[doc = " The number of syscalls that got blocked"]
6749 pub blocked_syscalls: usize,
6750 #[doc = " The total number of errors encountered since the last event"]
6751 pub total_errors: usize,
6752 #[doc = " The number of specific error codes dropped"]
6753 #[doc = ""]
6754 #[doc = " This can happen when a burst of errors exceeds the capacity of the recorder"]
6755 pub dropped_errors: usize,
6756 }
6757 impl IntoEvent<api::PlatformRx> for PlatformRx {
6758 #[inline]
6759 fn into_event(self) -> api::PlatformRx {
6760 let PlatformRx {
6761 count,
6762 syscalls,
6763 blocked_syscalls,
6764 total_errors,
6765 dropped_errors,
6766 } = self;
6767 api::PlatformRx {
6768 count: count.into_event(),
6769 syscalls: syscalls.into_event(),
6770 blocked_syscalls: blocked_syscalls.into_event(),
6771 total_errors: total_errors.into_event(),
6772 dropped_errors: dropped_errors.into_event(),
6773 }
6774 }
6775 }
6776 #[derive(Clone, Debug)]
6777 #[doc = " Emitted when the platform returns an error while receiving datagrams"]
6778 pub struct PlatformRxError {
6779 #[doc = " The error code returned by the platform"]
6780 pub errno: i32,
6781 }
6782 impl IntoEvent<api::PlatformRxError> for PlatformRxError {
6783 #[inline]
6784 fn into_event(self) -> api::PlatformRxError {
6785 let PlatformRxError { errno } = self;
6786 api::PlatformRxError {
6787 errno: errno.into_event(),
6788 }
6789 }
6790 }
6791 #[derive(Clone, Debug)]
6792 #[doc = " Emitted when a platform feature is configured"]
6793 pub struct PlatformFeatureConfigured {
6794 pub configuration: PlatformFeatureConfiguration,
6795 }
6796 impl IntoEvent<api::PlatformFeatureConfigured> for PlatformFeatureConfigured {
6797 #[inline]
6798 fn into_event(self) -> api::PlatformFeatureConfigured {
6799 let PlatformFeatureConfigured { configuration } = self;
6800 api::PlatformFeatureConfigured {
6801 configuration: configuration.into_event(),
6802 }
6803 }
6804 }
6805 #[derive(Clone, Debug)]
6806 pub struct PlatformEventLoopWakeup {
6807 pub timeout_expired: bool,
6808 pub rx_ready: bool,
6809 pub tx_ready: bool,
6810 pub application_wakeup: bool,
6811 }
6812 impl IntoEvent<api::PlatformEventLoopWakeup> for PlatformEventLoopWakeup {
6813 #[inline]
6814 fn into_event(self) -> api::PlatformEventLoopWakeup {
6815 let PlatformEventLoopWakeup {
6816 timeout_expired,
6817 rx_ready,
6818 tx_ready,
6819 application_wakeup,
6820 } = self;
6821 api::PlatformEventLoopWakeup {
6822 timeout_expired: timeout_expired.into_event(),
6823 rx_ready: rx_ready.into_event(),
6824 tx_ready: tx_ready.into_event(),
6825 application_wakeup: application_wakeup.into_event(),
6826 }
6827 }
6828 }
6829 #[derive(Clone, Debug)]
6830 pub struct PlatformEventLoopSleep {
6831 #[doc = " The next time at which the event loop will wake"]
6832 pub timeout: Option<core::time::Duration>,
6833 #[doc = " The amount of time spent processing endpoint events in a single event loop"]
6834 pub processing_duration: core::time::Duration,
6835 }
6836 impl IntoEvent<api::PlatformEventLoopSleep> for PlatformEventLoopSleep {
6837 #[inline]
6838 fn into_event(self) -> api::PlatformEventLoopSleep {
6839 let PlatformEventLoopSleep {
6840 timeout,
6841 processing_duration,
6842 } = self;
6843 api::PlatformEventLoopSleep {
6844 timeout: timeout.into_event(),
6845 processing_duration: processing_duration.into_event(),
6846 }
6847 }
6848 }
6849 #[derive(Clone, Debug)]
6850 pub struct PlatformEventLoopStarted<'a> {
6851 #[doc = " The local address of the socket"]
6852 pub local_address: SocketAddress<'a>,
6853 }
6854 impl<'a> IntoEvent<api::PlatformEventLoopStarted<'a>> for PlatformEventLoopStarted<'a> {
6855 #[inline]
6856 fn into_event(self) -> api::PlatformEventLoopStarted<'a> {
6857 let PlatformEventLoopStarted { local_address } = self;
6858 api::PlatformEventLoopStarted {
6859 local_address: local_address.into_event(),
6860 }
6861 }
6862 }
6863 #[derive(Clone, Debug)]
6864 pub enum PlatformFeatureConfiguration {
6865 #[doc = " Emitted when segment offload was configured"]
6866 Gso {
6867 #[doc = " The maximum number of segments that can be sent in a single GSO packet"]
6868 #[doc = ""]
6869 #[doc = " If this value not greater than 1, GSO is disabled."]
6870 max_segments: usize,
6871 },
6872 #[doc = " Emitted when receive segment offload was configured"]
6873 Gro { enabled: bool },
6874 #[doc = " Emitted when ECN support is configured"]
6875 Ecn { enabled: bool },
6876 #[doc = " Emitted when the base maximum transmission unit is configured"]
6877 BaseMtu { mtu: u16 },
6878 #[doc = " Emitted when the initial maximum transmission unit is configured"]
6879 InitialMtu { mtu: u16 },
6880 #[doc = " Emitted when the max maximum transmission unit is configured"]
6881 MaxMtu { mtu: u16 },
6882 }
6883 impl IntoEvent<api::PlatformFeatureConfiguration> for PlatformFeatureConfiguration {
6884 #[inline]
6885 fn into_event(self) -> api::PlatformFeatureConfiguration {
6886 use api::PlatformFeatureConfiguration::*;
6887 match self {
6888 Self::Gso { max_segments } => Gso {
6889 max_segments: max_segments.into_event(),
6890 },
6891 Self::Gro { enabled } => Gro {
6892 enabled: enabled.into_event(),
6893 },
6894 Self::Ecn { enabled } => Ecn {
6895 enabled: enabled.into_event(),
6896 },
6897 Self::BaseMtu { mtu } => BaseMtu {
6898 mtu: mtu.into_event(),
6899 },
6900 Self::InitialMtu { mtu } => InitialMtu {
6901 mtu: mtu.into_event(),
6902 },
6903 Self::MaxMtu { mtu } => MaxMtu {
6904 mtu: mtu.into_event(),
6905 },
6906 }
6907 }
6908 }
6909}
6910pub mod supervisor {
6911 #![doc = r" This module contains the `supervisor::Outcome` and `supervisor::Context` for use"]
6912 # and"]
6913 #"]
6914 #![doc = r" on a Subscriber."]
6915 use crate::{
6916 application,
6917 event::{builder::SocketAddress, IntoEvent},
6918 };
6919 #[non_exhaustive]
6920 #[derive(Clone, Debug, Eq, PartialEq)]
6921 pub enum Outcome {
6922 #[doc = r" Allow the connection to remain open"]
6923 Continue,
6924 #[doc = r" Close the connection and notify the peer"]
6925 Close { error_code: application::Error },
6926 #[doc = r" Close the connection without notifying the peer"]
6927 ImmediateClose { reason: &'static str },
6928 }
6929 impl Default for Outcome {
6930 fn default() -> Self {
6931 Self::Continue
6932 }
6933 }
6934 #[non_exhaustive]
6935 #[derive(Debug)]
6936 pub struct Context<'a> {
6937 #[doc = r" Number of handshakes that have begun but not completed"]
6938 pub inflight_handshakes: usize,
6939 #[doc = r" Number of open connections"]
6940 pub connection_count: usize,
6941 #[doc = r" The address of the peer"]
6942 pub remote_address: SocketAddress<'a>,
6943 #[doc = r" True if the connection is in the handshake state, false otherwise"]
6944 pub is_handshaking: bool,
6945 }
6946 impl<'a> Context<'a> {
6947 pub fn new(
6948 inflight_handshakes: usize,
6949 connection_count: usize,
6950 remote_address: &'a crate::inet::SocketAddress,
6951 is_handshaking: bool,
6952 ) -> Self {
6953 Self {
6954 inflight_handshakes,
6955 connection_count,
6956 remote_address: remote_address.into_event(),
6957 is_handshaking,
6958 }
6959 }
6960 }
6961}
6962pub use traits::*;
6963mod traits {
6964 use super::*;
6965 use crate::{event::Meta, query};
6966 use core::fmt;
6967 #[doc = r" Allows for events to be subscribed to"]
6968 pub trait Subscriber: 'static + Send {
6969 #[doc = r" An application provided type associated with each connection."]
6970 #[doc = r""]
6971 #[doc = r" The context provides a mechanism for applications to provide a custom type"]
6972 #[doc = r" and update it on each event, e.g. computing statistics. Each event"]
6973 #[doc = r" invocation (e.g. [`Subscriber::on_packet_sent`]) also provides mutable"]
6974 #[doc = r" access to the context `&mut ConnectionContext` and allows for updating the"]
6975 #[doc = r" context."]
6976 #[doc = r""]
6977 #[doc = r" ```no_run"]
6978 #[doc = r" # mod s2n_quic { pub mod provider { pub mod event {"]
6979 #[doc = r" # pub use s2n_quic_core::event::{api as events, api::ConnectionInfo, api::ConnectionMeta, Subscriber};"]
6980 #[doc = r" # }}}"]
6981 #[doc = r" use s2n_quic::provider::event::{"]
6982 #[doc = r" ConnectionInfo, ConnectionMeta, Subscriber, events::PacketSent"]
6983 #[doc = r" };"]
6984 #[doc = r""]
6985 #[doc = r" pub struct MyEventSubscriber;"]
6986 #[doc = r""]
6987 #[doc = r" pub struct MyEventContext {"]
6988 #[doc = r" packet_sent: u64,"]
6989 #[doc = r" }"]
6990 #[doc = r""]
6991 #[doc = r" impl Subscriber for MyEventSubscriber {"]
6992 #[doc = r" type ConnectionContext = MyEventContext;"]
6993 #[doc = r""]
6994 #[doc = r" fn create_connection_context("]
6995 #[doc = r" &mut self, _meta: &ConnectionMeta,"]
6996 #[doc = r" _info: &ConnectionInfo,"]
6997 #[doc = r" ) -> Self::ConnectionContext {"]
6998 #[doc = r" MyEventContext { packet_sent: 0 }"]
6999 #[doc = r" }"]
7000 #[doc = r""]
7001 #[doc = r" fn on_packet_sent("]
7002 #[doc = r" &mut self,"]
7003 #[doc = r" context: &mut Self::ConnectionContext,"]
7004 #[doc = r" _meta: &ConnectionMeta,"]
7005 #[doc = r" _event: &PacketSent,"]
7006 #[doc = r" ) {"]
7007 #[doc = r" context.packet_sent += 1;"]
7008 #[doc = r" }"]
7009 #[doc = r" }"]
7010 #[doc = r" ```"]
7011 type ConnectionContext: 'static + Send;
7012 #[doc = r" Creates a context to be passed to each connection-related event"]
7013 fn create_connection_context(
7014 &mut self,
7015 meta: &api::ConnectionMeta,
7016 info: &api::ConnectionInfo,
7017 ) -> Self::ConnectionContext;
7018 #[doc = r" The period at which `on_supervisor_timeout` is called"]
7019 #[doc = r""]
7020 #[doc = r" If multiple `event::Subscriber`s are composed together, the minimum `supervisor_timeout`"]
7021 #[doc = r" across all `event::Subscriber`s will be used."]
7022 #[doc = r""]
7023 #[doc = r" If the `supervisor_timeout()` is `None` across all `event::Subscriber`s, connection supervision"]
7024 #[doc = r" will cease for the remaining lifetime of the connection and `on_supervisor_timeout` will no longer"]
7025 #[doc = r" be called."]
7026 #[doc = r""]
7027 #[doc = r" It is recommended to avoid setting this value less than ~100ms, as short durations"]
7028 #[doc = r" may lead to higher CPU utilization."]
7029 #[allow(unused_variables)]
7030 fn supervisor_timeout(
7031 &mut self,
7032 conn_context: &mut Self::ConnectionContext,
7033 meta: &api::ConnectionMeta,
7034 context: &supervisor::Context,
7035 ) -> Option<Duration> {
7036 None
7037 }
7038 #[doc = r" Called for each `supervisor_timeout` to determine any action to take on the connection based on the `supervisor::Outcome`"]
7039 #[doc = r""]
7040 #[doc = r" If multiple `event::Subscriber`s are composed together, the minimum `supervisor_timeout`"]
7041 #[doc = r" across all `event::Subscriber`s will be used, and thus `on_supervisor_timeout` may be called"]
7042 #[doc = r" earlier than the `supervisor_timeout` for a given `event::Subscriber` implementation."]
7043 #[allow(unused_variables)]
7044 fn on_supervisor_timeout(
7045 &mut self,
7046 conn_context: &mut Self::ConnectionContext,
7047 meta: &api::ConnectionMeta,
7048 context: &supervisor::Context,
7049 ) -> supervisor::Outcome {
7050 supervisor::Outcome::default()
7051 }
7052 #[doc = "Called when the `ApplicationProtocolInformation` event is triggered"]
7053 #[inline]
7054 fn on_application_protocol_information(
7055 &mut self,
7056 context: &mut Self::ConnectionContext,
7057 meta: &api::ConnectionMeta,
7058 event: &api::ApplicationProtocolInformation,
7059 ) {
7060 let _ = context;
7061 let _ = meta;
7062 let _ = event;
7063 }
7064 #[doc = "Called when the `ServerNameInformation` event is triggered"]
7065 #[inline]
7066 fn on_server_name_information(
7067 &mut self,
7068 context: &mut Self::ConnectionContext,
7069 meta: &api::ConnectionMeta,
7070 event: &api::ServerNameInformation,
7071 ) {
7072 let _ = context;
7073 let _ = meta;
7074 let _ = event;
7075 }
7076 #[doc = "Called when the `KeyExchangeGroup` event is triggered"]
7077 #[inline]
7078 fn on_key_exchange_group(
7079 &mut self,
7080 context: &mut Self::ConnectionContext,
7081 meta: &api::ConnectionMeta,
7082 event: &api::KeyExchangeGroup,
7083 ) {
7084 let _ = context;
7085 let _ = meta;
7086 let _ = event;
7087 }
7088 #[doc = "Called when the `PacketSkipped` event is triggered"]
7089 #[inline]
7090 fn on_packet_skipped(
7091 &mut self,
7092 context: &mut Self::ConnectionContext,
7093 meta: &api::ConnectionMeta,
7094 event: &api::PacketSkipped,
7095 ) {
7096 let _ = context;
7097 let _ = meta;
7098 let _ = event;
7099 }
7100 #[doc = "Called when the `PacketSent` event is triggered"]
7101 #[inline]
7102 fn on_packet_sent(
7103 &mut self,
7104 context: &mut Self::ConnectionContext,
7105 meta: &api::ConnectionMeta,
7106 event: &api::PacketSent,
7107 ) {
7108 let _ = context;
7109 let _ = meta;
7110 let _ = event;
7111 }
7112 #[doc = "Called when the `PacketReceived` event is triggered"]
7113 #[inline]
7114 fn on_packet_received(
7115 &mut self,
7116 context: &mut Self::ConnectionContext,
7117 meta: &api::ConnectionMeta,
7118 event: &api::PacketReceived,
7119 ) {
7120 let _ = context;
7121 let _ = meta;
7122 let _ = event;
7123 }
7124 #[doc = "Called when the `ActivePathUpdated` event is triggered"]
7125 #[inline]
7126 fn on_active_path_updated(
7127 &mut self,
7128 context: &mut Self::ConnectionContext,
7129 meta: &api::ConnectionMeta,
7130 event: &api::ActivePathUpdated,
7131 ) {
7132 let _ = context;
7133 let _ = meta;
7134 let _ = event;
7135 }
7136 #[doc = "Called when the `PathCreated` event is triggered"]
7137 #[inline]
7138 fn on_path_created(
7139 &mut self,
7140 context: &mut Self::ConnectionContext,
7141 meta: &api::ConnectionMeta,
7142 event: &api::PathCreated,
7143 ) {
7144 let _ = context;
7145 let _ = meta;
7146 let _ = event;
7147 }
7148 #[doc = "Called when the `FrameSent` event is triggered"]
7149 #[inline]
7150 fn on_frame_sent(
7151 &mut self,
7152 context: &mut Self::ConnectionContext,
7153 meta: &api::ConnectionMeta,
7154 event: &api::FrameSent,
7155 ) {
7156 let _ = context;
7157 let _ = meta;
7158 let _ = event;
7159 }
7160 #[doc = "Called when the `FrameReceived` event is triggered"]
7161 #[inline]
7162 fn on_frame_received(
7163 &mut self,
7164 context: &mut Self::ConnectionContext,
7165 meta: &api::ConnectionMeta,
7166 event: &api::FrameReceived,
7167 ) {
7168 let _ = context;
7169 let _ = meta;
7170 let _ = event;
7171 }
7172 #[doc = "Called when the `ConnectionCloseFrameReceived` event is triggered"]
7173 #[inline]
7174 fn on_connection_close_frame_received(
7175 &mut self,
7176 context: &mut Self::ConnectionContext,
7177 meta: &api::ConnectionMeta,
7178 event: &api::ConnectionCloseFrameReceived,
7179 ) {
7180 let _ = context;
7181 let _ = meta;
7182 let _ = event;
7183 }
7184 #[doc = "Called when the `PacketLost` event is triggered"]
7185 #[inline]
7186 fn on_packet_lost(
7187 &mut self,
7188 context: &mut Self::ConnectionContext,
7189 meta: &api::ConnectionMeta,
7190 event: &api::PacketLost,
7191 ) {
7192 let _ = context;
7193 let _ = meta;
7194 let _ = event;
7195 }
7196 #[doc = "Called when the `RecoveryMetrics` event is triggered"]
7197 #[inline]
7198 fn on_recovery_metrics(
7199 &mut self,
7200 context: &mut Self::ConnectionContext,
7201 meta: &api::ConnectionMeta,
7202 event: &api::RecoveryMetrics,
7203 ) {
7204 let _ = context;
7205 let _ = meta;
7206 let _ = event;
7207 }
7208 #[doc = "Called when the `Congestion` event is triggered"]
7209 #[inline]
7210 fn on_congestion(
7211 &mut self,
7212 context: &mut Self::ConnectionContext,
7213 meta: &api::ConnectionMeta,
7214 event: &api::Congestion,
7215 ) {
7216 let _ = context;
7217 let _ = meta;
7218 let _ = event;
7219 }
7220 #[doc = "Called when the `AckProcessed` event is triggered"]
7221 #[inline]
7222 #[deprecated(note = "use on_rx_ack_range_dropped event instead")]
7223 #[allow(deprecated)]
7224 fn on_ack_processed(
7225 &mut self,
7226 context: &mut Self::ConnectionContext,
7227 meta: &api::ConnectionMeta,
7228 event: &api::AckProcessed,
7229 ) {
7230 let _ = context;
7231 let _ = meta;
7232 let _ = event;
7233 }
7234 #[doc = "Called when the `RxAckRangeDropped` event is triggered"]
7235 #[inline]
7236 fn on_rx_ack_range_dropped(
7237 &mut self,
7238 context: &mut Self::ConnectionContext,
7239 meta: &api::ConnectionMeta,
7240 event: &api::RxAckRangeDropped,
7241 ) {
7242 let _ = context;
7243 let _ = meta;
7244 let _ = event;
7245 }
7246 #[doc = "Called when the `AckRangeReceived` event is triggered"]
7247 #[inline]
7248 fn on_ack_range_received(
7249 &mut self,
7250 context: &mut Self::ConnectionContext,
7251 meta: &api::ConnectionMeta,
7252 event: &api::AckRangeReceived,
7253 ) {
7254 let _ = context;
7255 let _ = meta;
7256 let _ = event;
7257 }
7258 #[doc = "Called when the `AckRangeSent` event is triggered"]
7259 #[inline]
7260 fn on_ack_range_sent(
7261 &mut self,
7262 context: &mut Self::ConnectionContext,
7263 meta: &api::ConnectionMeta,
7264 event: &api::AckRangeSent,
7265 ) {
7266 let _ = context;
7267 let _ = meta;
7268 let _ = event;
7269 }
7270 #[doc = "Called when the `PacketDropped` event is triggered"]
7271 #[inline]
7272 fn on_packet_dropped(
7273 &mut self,
7274 context: &mut Self::ConnectionContext,
7275 meta: &api::ConnectionMeta,
7276 event: &api::PacketDropped,
7277 ) {
7278 let _ = context;
7279 let _ = meta;
7280 let _ = event;
7281 }
7282 #[doc = "Called when the `KeyUpdate` event is triggered"]
7283 #[inline]
7284 fn on_key_update(
7285 &mut self,
7286 context: &mut Self::ConnectionContext,
7287 meta: &api::ConnectionMeta,
7288 event: &api::KeyUpdate,
7289 ) {
7290 let _ = context;
7291 let _ = meta;
7292 let _ = event;
7293 }
7294 #[doc = "Called when the `KeySpaceDiscarded` event is triggered"]
7295 #[inline]
7296 fn on_key_space_discarded(
7297 &mut self,
7298 context: &mut Self::ConnectionContext,
7299 meta: &api::ConnectionMeta,
7300 event: &api::KeySpaceDiscarded,
7301 ) {
7302 let _ = context;
7303 let _ = meta;
7304 let _ = event;
7305 }
7306 #[doc = "Called when the `ConnectionStarted` event is triggered"]
7307 #[inline]
7308 fn on_connection_started(
7309 &mut self,
7310 context: &mut Self::ConnectionContext,
7311 meta: &api::ConnectionMeta,
7312 event: &api::ConnectionStarted,
7313 ) {
7314 let _ = context;
7315 let _ = meta;
7316 let _ = event;
7317 }
7318 #[doc = "Called when the `DuplicatePacket` event is triggered"]
7319 #[inline]
7320 fn on_duplicate_packet(
7321 &mut self,
7322 context: &mut Self::ConnectionContext,
7323 meta: &api::ConnectionMeta,
7324 event: &api::DuplicatePacket,
7325 ) {
7326 let _ = context;
7327 let _ = meta;
7328 let _ = event;
7329 }
7330 #[doc = "Called when the `TransportParametersReceived` event is triggered"]
7331 #[inline]
7332 fn on_transport_parameters_received(
7333 &mut self,
7334 context: &mut Self::ConnectionContext,
7335 meta: &api::ConnectionMeta,
7336 event: &api::TransportParametersReceived,
7337 ) {
7338 let _ = context;
7339 let _ = meta;
7340 let _ = event;
7341 }
7342 #[doc = "Called when the `DatagramSent` event is triggered"]
7343 #[inline]
7344 fn on_datagram_sent(
7345 &mut self,
7346 context: &mut Self::ConnectionContext,
7347 meta: &api::ConnectionMeta,
7348 event: &api::DatagramSent,
7349 ) {
7350 let _ = context;
7351 let _ = meta;
7352 let _ = event;
7353 }
7354 #[doc = "Called when the `DatagramReceived` event is triggered"]
7355 #[inline]
7356 fn on_datagram_received(
7357 &mut self,
7358 context: &mut Self::ConnectionContext,
7359 meta: &api::ConnectionMeta,
7360 event: &api::DatagramReceived,
7361 ) {
7362 let _ = context;
7363 let _ = meta;
7364 let _ = event;
7365 }
7366 #[doc = "Called when the `DatagramDropped` event is triggered"]
7367 #[inline]
7368 fn on_datagram_dropped(
7369 &mut self,
7370 context: &mut Self::ConnectionContext,
7371 meta: &api::ConnectionMeta,
7372 event: &api::DatagramDropped,
7373 ) {
7374 let _ = context;
7375 let _ = meta;
7376 let _ = event;
7377 }
7378 #[doc = "Called when the `HandshakeRemoteAddressChangeObserved` event is triggered"]
7379 #[inline]
7380 fn on_handshake_remote_address_change_observed(
7381 &mut self,
7382 context: &mut Self::ConnectionContext,
7383 meta: &api::ConnectionMeta,
7384 event: &api::HandshakeRemoteAddressChangeObserved,
7385 ) {
7386 let _ = context;
7387 let _ = meta;
7388 let _ = event;
7389 }
7390 #[doc = "Called when the `ConnectionIdUpdated` event is triggered"]
7391 #[inline]
7392 fn on_connection_id_updated(
7393 &mut self,
7394 context: &mut Self::ConnectionContext,
7395 meta: &api::ConnectionMeta,
7396 event: &api::ConnectionIdUpdated,
7397 ) {
7398 let _ = context;
7399 let _ = meta;
7400 let _ = event;
7401 }
7402 #[doc = "Called when the `EcnStateChanged` event is triggered"]
7403 #[inline]
7404 fn on_ecn_state_changed(
7405 &mut self,
7406 context: &mut Self::ConnectionContext,
7407 meta: &api::ConnectionMeta,
7408 event: &api::EcnStateChanged,
7409 ) {
7410 let _ = context;
7411 let _ = meta;
7412 let _ = event;
7413 }
7414 #[doc = "Called when the `ConnectionMigrationDenied` event is triggered"]
7415 #[inline]
7416 fn on_connection_migration_denied(
7417 &mut self,
7418 context: &mut Self::ConnectionContext,
7419 meta: &api::ConnectionMeta,
7420 event: &api::ConnectionMigrationDenied,
7421 ) {
7422 let _ = context;
7423 let _ = meta;
7424 let _ = event;
7425 }
7426 #[doc = "Called when the `HandshakeStatusUpdated` event is triggered"]
7427 #[inline]
7428 fn on_handshake_status_updated(
7429 &mut self,
7430 context: &mut Self::ConnectionContext,
7431 meta: &api::ConnectionMeta,
7432 event: &api::HandshakeStatusUpdated,
7433 ) {
7434 let _ = context;
7435 let _ = meta;
7436 let _ = event;
7437 }
7438 #[doc = "Called when the `TlsExporterReady` event is triggered"]
7439 #[inline]
7440 fn on_tls_exporter_ready(
7441 &mut self,
7442 context: &mut Self::ConnectionContext,
7443 meta: &api::ConnectionMeta,
7444 event: &api::TlsExporterReady,
7445 ) {
7446 let _ = context;
7447 let _ = meta;
7448 let _ = event;
7449 }
7450 #[doc = "Called when the `TlsHandshakeFailed` event is triggered"]
7451 #[inline]
7452 fn on_tls_handshake_failed(
7453 &mut self,
7454 context: &mut Self::ConnectionContext,
7455 meta: &api::ConnectionMeta,
7456 event: &api::TlsHandshakeFailed,
7457 ) {
7458 let _ = context;
7459 let _ = meta;
7460 let _ = event;
7461 }
7462 #[doc = "Called when the `PathChallengeUpdated` event is triggered"]
7463 #[inline]
7464 fn on_path_challenge_updated(
7465 &mut self,
7466 context: &mut Self::ConnectionContext,
7467 meta: &api::ConnectionMeta,
7468 event: &api::PathChallengeUpdated,
7469 ) {
7470 let _ = context;
7471 let _ = meta;
7472 let _ = event;
7473 }
7474 #[doc = "Called when the `TlsClientHello` event is triggered"]
7475 #[inline]
7476 fn on_tls_client_hello(
7477 &mut self,
7478 context: &mut Self::ConnectionContext,
7479 meta: &api::ConnectionMeta,
7480 event: &api::TlsClientHello,
7481 ) {
7482 let _ = context;
7483 let _ = meta;
7484 let _ = event;
7485 }
7486 #[doc = "Called when the `TlsServerHello` event is triggered"]
7487 #[inline]
7488 fn on_tls_server_hello(
7489 &mut self,
7490 context: &mut Self::ConnectionContext,
7491 meta: &api::ConnectionMeta,
7492 event: &api::TlsServerHello,
7493 ) {
7494 let _ = context;
7495 let _ = meta;
7496 let _ = event;
7497 }
7498 #[doc = "Called when the `RxStreamProgress` event is triggered"]
7499 #[inline]
7500 fn on_rx_stream_progress(
7501 &mut self,
7502 context: &mut Self::ConnectionContext,
7503 meta: &api::ConnectionMeta,
7504 event: &api::RxStreamProgress,
7505 ) {
7506 let _ = context;
7507 let _ = meta;
7508 let _ = event;
7509 }
7510 #[doc = "Called when the `TxStreamProgress` event is triggered"]
7511 #[inline]
7512 fn on_tx_stream_progress(
7513 &mut self,
7514 context: &mut Self::ConnectionContext,
7515 meta: &api::ConnectionMeta,
7516 event: &api::TxStreamProgress,
7517 ) {
7518 let _ = context;
7519 let _ = meta;
7520 let _ = event;
7521 }
7522 #[doc = "Called when the `KeepAliveTimerExpired` event is triggered"]
7523 #[inline]
7524 fn on_keep_alive_timer_expired(
7525 &mut self,
7526 context: &mut Self::ConnectionContext,
7527 meta: &api::ConnectionMeta,
7528 event: &api::KeepAliveTimerExpired,
7529 ) {
7530 let _ = context;
7531 let _ = meta;
7532 let _ = event;
7533 }
7534 #[doc = "Called when the `MtuUpdated` event is triggered"]
7535 #[inline]
7536 fn on_mtu_updated(
7537 &mut self,
7538 context: &mut Self::ConnectionContext,
7539 meta: &api::ConnectionMeta,
7540 event: &api::MtuUpdated,
7541 ) {
7542 let _ = context;
7543 let _ = meta;
7544 let _ = event;
7545 }
7546 #[doc = "Called when the `SlowStartExited` event is triggered"]
7547 #[inline]
7548 fn on_slow_start_exited(
7549 &mut self,
7550 context: &mut Self::ConnectionContext,
7551 meta: &api::ConnectionMeta,
7552 event: &api::SlowStartExited,
7553 ) {
7554 let _ = context;
7555 let _ = meta;
7556 let _ = event;
7557 }
7558 #[doc = "Called when the `DeliveryRateSampled` event is triggered"]
7559 #[inline]
7560 fn on_delivery_rate_sampled(
7561 &mut self,
7562 context: &mut Self::ConnectionContext,
7563 meta: &api::ConnectionMeta,
7564 event: &api::DeliveryRateSampled,
7565 ) {
7566 let _ = context;
7567 let _ = meta;
7568 let _ = event;
7569 }
7570 #[doc = "Called when the `PacingRateUpdated` event is triggered"]
7571 #[inline]
7572 fn on_pacing_rate_updated(
7573 &mut self,
7574 context: &mut Self::ConnectionContext,
7575 meta: &api::ConnectionMeta,
7576 event: &api::PacingRateUpdated,
7577 ) {
7578 let _ = context;
7579 let _ = meta;
7580 let _ = event;
7581 }
7582 #[doc = "Called when the `BbrStateChanged` event is triggered"]
7583 #[inline]
7584 fn on_bbr_state_changed(
7585 &mut self,
7586 context: &mut Self::ConnectionContext,
7587 meta: &api::ConnectionMeta,
7588 event: &api::BbrStateChanged,
7589 ) {
7590 let _ = context;
7591 let _ = meta;
7592 let _ = event;
7593 }
7594 #[doc = "Called when the `DcStateChanged` event is triggered"]
7595 #[inline]
7596 fn on_dc_state_changed(
7597 &mut self,
7598 context: &mut Self::ConnectionContext,
7599 meta: &api::ConnectionMeta,
7600 event: &api::DcStateChanged,
7601 ) {
7602 let _ = context;
7603 let _ = meta;
7604 let _ = event;
7605 }
7606 #[doc = "Called when the `DcPathCreated` event is triggered"]
7607 #[inline]
7608 fn on_dc_path_created(
7609 &mut self,
7610 context: &mut Self::ConnectionContext,
7611 meta: &api::ConnectionMeta,
7612 event: &api::DcPathCreated,
7613 ) {
7614 let _ = context;
7615 let _ = meta;
7616 let _ = event;
7617 }
7618 #[doc = "Called when the `ConnectionClosed` event is triggered"]
7619 #[inline]
7620 fn on_connection_closed(
7621 &mut self,
7622 context: &mut Self::ConnectionContext,
7623 meta: &api::ConnectionMeta,
7624 event: &api::ConnectionClosed,
7625 ) {
7626 let _ = context;
7627 let _ = meta;
7628 let _ = event;
7629 }
7630 #[doc = "Called when the `VersionInformation` event is triggered"]
7631 #[inline]
7632 fn on_version_information(
7633 &mut self,
7634 meta: &api::EndpointMeta,
7635 event: &api::VersionInformation,
7636 ) {
7637 let _ = meta;
7638 let _ = event;
7639 }
7640 #[doc = "Called when the `EndpointPacketSent` event is triggered"]
7641 #[inline]
7642 fn on_endpoint_packet_sent(
7643 &mut self,
7644 meta: &api::EndpointMeta,
7645 event: &api::EndpointPacketSent,
7646 ) {
7647 let _ = meta;
7648 let _ = event;
7649 }
7650 #[doc = "Called when the `EndpointPacketReceived` event is triggered"]
7651 #[inline]
7652 fn on_endpoint_packet_received(
7653 &mut self,
7654 meta: &api::EndpointMeta,
7655 event: &api::EndpointPacketReceived,
7656 ) {
7657 let _ = meta;
7658 let _ = event;
7659 }
7660 #[doc = "Called when the `EndpointDatagramSent` event is triggered"]
7661 #[inline]
7662 fn on_endpoint_datagram_sent(
7663 &mut self,
7664 meta: &api::EndpointMeta,
7665 event: &api::EndpointDatagramSent,
7666 ) {
7667 let _ = meta;
7668 let _ = event;
7669 }
7670 #[doc = "Called when the `EndpointDatagramReceived` event is triggered"]
7671 #[inline]
7672 fn on_endpoint_datagram_received(
7673 &mut self,
7674 meta: &api::EndpointMeta,
7675 event: &api::EndpointDatagramReceived,
7676 ) {
7677 let _ = meta;
7678 let _ = event;
7679 }
7680 #[doc = "Called when the `EndpointDatagramDropped` event is triggered"]
7681 #[inline]
7682 fn on_endpoint_datagram_dropped(
7683 &mut self,
7684 meta: &api::EndpointMeta,
7685 event: &api::EndpointDatagramDropped,
7686 ) {
7687 let _ = meta;
7688 let _ = event;
7689 }
7690 #[doc = "Called when the `EndpointConnectionAttemptFailed` event is triggered"]
7691 #[inline]
7692 fn on_endpoint_connection_attempt_failed(
7693 &mut self,
7694 meta: &api::EndpointMeta,
7695 event: &api::EndpointConnectionAttemptFailed,
7696 ) {
7697 let _ = meta;
7698 let _ = event;
7699 }
7700 #[doc = "Called when the `EndpointConnectionAttemptDeduplicated` event is triggered"]
7701 #[inline]
7702 fn on_endpoint_connection_attempt_deduplicated(
7703 &mut self,
7704 meta: &api::EndpointMeta,
7705 event: &api::EndpointConnectionAttemptDeduplicated,
7706 ) {
7707 let _ = meta;
7708 let _ = event;
7709 }
7710 #[doc = "Called when the `PlatformTx` event is triggered"]
7711 #[inline]
7712 fn on_platform_tx(&mut self, meta: &api::EndpointMeta, event: &api::PlatformTx) {
7713 let _ = meta;
7714 let _ = event;
7715 }
7716 #[doc = "Called when the `PlatformTxError` event is triggered"]
7717 #[inline]
7718 fn on_platform_tx_error(&mut self, meta: &api::EndpointMeta, event: &api::PlatformTxError) {
7719 let _ = meta;
7720 let _ = event;
7721 }
7722 #[doc = "Called when the `PlatformRx` event is triggered"]
7723 #[inline]
7724 fn on_platform_rx(&mut self, meta: &api::EndpointMeta, event: &api::PlatformRx) {
7725 let _ = meta;
7726 let _ = event;
7727 }
7728 #[doc = "Called when the `PlatformRxError` event is triggered"]
7729 #[inline]
7730 fn on_platform_rx_error(&mut self, meta: &api::EndpointMeta, event: &api::PlatformRxError) {
7731 let _ = meta;
7732 let _ = event;
7733 }
7734 #[doc = "Called when the `PlatformFeatureConfigured` event is triggered"]
7735 #[inline]
7736 fn on_platform_feature_configured(
7737 &mut self,
7738 meta: &api::EndpointMeta,
7739 event: &api::PlatformFeatureConfigured,
7740 ) {
7741 let _ = meta;
7742 let _ = event;
7743 }
7744 #[doc = "Called when the `PlatformEventLoopWakeup` event is triggered"]
7745 #[inline]
7746 fn on_platform_event_loop_wakeup(
7747 &mut self,
7748 meta: &api::EndpointMeta,
7749 event: &api::PlatformEventLoopWakeup,
7750 ) {
7751 let _ = meta;
7752 let _ = event;
7753 }
7754 #[doc = "Called when the `PlatformEventLoopSleep` event is triggered"]
7755 #[inline]
7756 fn on_platform_event_loop_sleep(
7757 &mut self,
7758 meta: &api::EndpointMeta,
7759 event: &api::PlatformEventLoopSleep,
7760 ) {
7761 let _ = meta;
7762 let _ = event;
7763 }
7764 #[doc = "Called when the `PlatformEventLoopStarted` event is triggered"]
7765 #[inline]
7766 fn on_platform_event_loop_started(
7767 &mut self,
7768 meta: &api::EndpointMeta,
7769 event: &api::PlatformEventLoopStarted,
7770 ) {
7771 let _ = meta;
7772 let _ = event;
7773 }
7774 #[doc = r" Called for each event that relates to the endpoint and all connections"]
7775 #[inline]
7776 fn on_event<M: Meta, E: Event>(&mut self, meta: &M, event: &E) {
7777 let _ = meta;
7778 let _ = event;
7779 }
7780 #[doc = r" Called for each event that relates to a connection"]
7781 #[inline]
7782 fn on_connection_event<E: Event>(
7783 &mut self,
7784 context: &mut Self::ConnectionContext,
7785 meta: &api::ConnectionMeta,
7786 event: &E,
7787 ) {
7788 let _ = context;
7789 let _ = meta;
7790 let _ = event;
7791 }
7792 #[doc = r" Used for querying the `Subscriber::ConnectionContext` on a Subscriber"]
7793 #[inline]
7794 fn query(
7795 context: &Self::ConnectionContext,
7796 query: &mut dyn query::Query,
7797 ) -> query::ControlFlow {
7798 query.execute(context)
7799 }
7800 #[doc = r" Used for querying and mutating the `Subscriber::ConnectionContext` on a Subscriber"]
7801 #[inline]
7802 fn query_mut(
7803 context: &mut Self::ConnectionContext,
7804 query: &mut dyn query::QueryMut,
7805 ) -> query::ControlFlow {
7806 query.execute_mut(context)
7807 }
7808 }
7809 #[doc = r" Subscriber is implemented for a 2-element tuple to make it easy to compose multiple"]
7810 #[doc = r" subscribers."]
7811 impl<A, B> Subscriber for (A, B)
7812 where
7813 A: Subscriber,
7814 B: Subscriber,
7815 {
7816 type ConnectionContext = (A::ConnectionContext, B::ConnectionContext);
7817 #[inline]
7818 fn create_connection_context(
7819 &mut self,
7820 meta: &api::ConnectionMeta,
7821 info: &api::ConnectionInfo,
7822 ) -> Self::ConnectionContext {
7823 (
7824 self.0.create_connection_context(meta, info),
7825 self.1.create_connection_context(meta, info),
7826 )
7827 }
7828 #[inline]
7829 fn supervisor_timeout(
7830 &mut self,
7831 conn_context: &mut Self::ConnectionContext,
7832 meta: &api::ConnectionMeta,
7833 context: &supervisor::Context,
7834 ) -> Option<Duration> {
7835 let timeout_a = self
7836 .0
7837 .supervisor_timeout(&mut conn_context.0, meta, context);
7838 let timeout_b = self
7839 .1
7840 .supervisor_timeout(&mut conn_context.1, meta, context);
7841 match (timeout_a, timeout_b) {
7842 (None, None) => None,
7843 (None, Some(timeout)) | (Some(timeout), None) => Some(timeout),
7844 (Some(a), Some(b)) => Some(a.min(b)),
7845 }
7846 }
7847 #[inline]
7848 fn on_supervisor_timeout(
7849 &mut self,
7850 conn_context: &mut Self::ConnectionContext,
7851 meta: &api::ConnectionMeta,
7852 context: &supervisor::Context,
7853 ) -> supervisor::Outcome {
7854 let outcome_a = self
7855 .0
7856 .on_supervisor_timeout(&mut conn_context.0, meta, context);
7857 let outcome_b = self
7858 .1
7859 .on_supervisor_timeout(&mut conn_context.1, meta, context);
7860 match (outcome_a, outcome_b) {
7861 (supervisor::Outcome::ImmediateClose { reason }, _)
7862 | (_, supervisor::Outcome::ImmediateClose { reason }) => {
7863 supervisor::Outcome::ImmediateClose { reason }
7864 }
7865 (supervisor::Outcome::Close { error_code }, _)
7866 | (_, supervisor::Outcome::Close { error_code }) => {
7867 supervisor::Outcome::Close { error_code }
7868 }
7869 _ => supervisor::Outcome::Continue,
7870 }
7871 }
7872 #[inline]
7873 fn on_application_protocol_information(
7874 &mut self,
7875 context: &mut Self::ConnectionContext,
7876 meta: &api::ConnectionMeta,
7877 event: &api::ApplicationProtocolInformation,
7878 ) {
7879 (self.0).on_application_protocol_information(&mut context.0, meta, event);
7880 (self.1).on_application_protocol_information(&mut context.1, meta, event);
7881 }
7882 #[inline]
7883 fn on_server_name_information(
7884 &mut self,
7885 context: &mut Self::ConnectionContext,
7886 meta: &api::ConnectionMeta,
7887 event: &api::ServerNameInformation,
7888 ) {
7889 (self.0).on_server_name_information(&mut context.0, meta, event);
7890 (self.1).on_server_name_information(&mut context.1, meta, event);
7891 }
7892 #[inline]
7893 fn on_key_exchange_group(
7894 &mut self,
7895 context: &mut Self::ConnectionContext,
7896 meta: &api::ConnectionMeta,
7897 event: &api::KeyExchangeGroup,
7898 ) {
7899 (self.0).on_key_exchange_group(&mut context.0, meta, event);
7900 (self.1).on_key_exchange_group(&mut context.1, meta, event);
7901 }
7902 #[inline]
7903 fn on_packet_skipped(
7904 &mut self,
7905 context: &mut Self::ConnectionContext,
7906 meta: &api::ConnectionMeta,
7907 event: &api::PacketSkipped,
7908 ) {
7909 (self.0).on_packet_skipped(&mut context.0, meta, event);
7910 (self.1).on_packet_skipped(&mut context.1, meta, event);
7911 }
7912 #[inline]
7913 fn on_packet_sent(
7914 &mut self,
7915 context: &mut Self::ConnectionContext,
7916 meta: &api::ConnectionMeta,
7917 event: &api::PacketSent,
7918 ) {
7919 (self.0).on_packet_sent(&mut context.0, meta, event);
7920 (self.1).on_packet_sent(&mut context.1, meta, event);
7921 }
7922 #[inline]
7923 fn on_packet_received(
7924 &mut self,
7925 context: &mut Self::ConnectionContext,
7926 meta: &api::ConnectionMeta,
7927 event: &api::PacketReceived,
7928 ) {
7929 (self.0).on_packet_received(&mut context.0, meta, event);
7930 (self.1).on_packet_received(&mut context.1, meta, event);
7931 }
7932 #[inline]
7933 fn on_active_path_updated(
7934 &mut self,
7935 context: &mut Self::ConnectionContext,
7936 meta: &api::ConnectionMeta,
7937 event: &api::ActivePathUpdated,
7938 ) {
7939 (self.0).on_active_path_updated(&mut context.0, meta, event);
7940 (self.1).on_active_path_updated(&mut context.1, meta, event);
7941 }
7942 #[inline]
7943 fn on_path_created(
7944 &mut self,
7945 context: &mut Self::ConnectionContext,
7946 meta: &api::ConnectionMeta,
7947 event: &api::PathCreated,
7948 ) {
7949 (self.0).on_path_created(&mut context.0, meta, event);
7950 (self.1).on_path_created(&mut context.1, meta, event);
7951 }
7952 #[inline]
7953 fn on_frame_sent(
7954 &mut self,
7955 context: &mut Self::ConnectionContext,
7956 meta: &api::ConnectionMeta,
7957 event: &api::FrameSent,
7958 ) {
7959 (self.0).on_frame_sent(&mut context.0, meta, event);
7960 (self.1).on_frame_sent(&mut context.1, meta, event);
7961 }
7962 #[inline]
7963 fn on_frame_received(
7964 &mut self,
7965 context: &mut Self::ConnectionContext,
7966 meta: &api::ConnectionMeta,
7967 event: &api::FrameReceived,
7968 ) {
7969 (self.0).on_frame_received(&mut context.0, meta, event);
7970 (self.1).on_frame_received(&mut context.1, meta, event);
7971 }
7972 #[inline]
7973 fn on_connection_close_frame_received(
7974 &mut self,
7975 context: &mut Self::ConnectionContext,
7976 meta: &api::ConnectionMeta,
7977 event: &api::ConnectionCloseFrameReceived,
7978 ) {
7979 (self.0).on_connection_close_frame_received(&mut context.0, meta, event);
7980 (self.1).on_connection_close_frame_received(&mut context.1, meta, event);
7981 }
7982 #[inline]
7983 fn on_packet_lost(
7984 &mut self,
7985 context: &mut Self::ConnectionContext,
7986 meta: &api::ConnectionMeta,
7987 event: &api::PacketLost,
7988 ) {
7989 (self.0).on_packet_lost(&mut context.0, meta, event);
7990 (self.1).on_packet_lost(&mut context.1, meta, event);
7991 }
7992 #[inline]
7993 fn on_recovery_metrics(
7994 &mut self,
7995 context: &mut Self::ConnectionContext,
7996 meta: &api::ConnectionMeta,
7997 event: &api::RecoveryMetrics,
7998 ) {
7999 (self.0).on_recovery_metrics(&mut context.0, meta, event);
8000 (self.1).on_recovery_metrics(&mut context.1, meta, event);
8001 }
8002 #[inline]
8003 fn on_congestion(
8004 &mut self,
8005 context: &mut Self::ConnectionContext,
8006 meta: &api::ConnectionMeta,
8007 event: &api::Congestion,
8008 ) {
8009 (self.0).on_congestion(&mut context.0, meta, event);
8010 (self.1).on_congestion(&mut context.1, meta, event);
8011 }
8012 #[inline]
8013 #[allow(deprecated)]
8014 fn on_ack_processed(
8015 &mut self,
8016 context: &mut Self::ConnectionContext,
8017 meta: &api::ConnectionMeta,
8018 event: &api::AckProcessed,
8019 ) {
8020 (self.0).on_ack_processed(&mut context.0, meta, event);
8021 (self.1).on_ack_processed(&mut context.1, meta, event);
8022 }
8023 #[inline]
8024 fn on_rx_ack_range_dropped(
8025 &mut self,
8026 context: &mut Self::ConnectionContext,
8027 meta: &api::ConnectionMeta,
8028 event: &api::RxAckRangeDropped,
8029 ) {
8030 (self.0).on_rx_ack_range_dropped(&mut context.0, meta, event);
8031 (self.1).on_rx_ack_range_dropped(&mut context.1, meta, event);
8032 }
8033 #[inline]
8034 fn on_ack_range_received(
8035 &mut self,
8036 context: &mut Self::ConnectionContext,
8037 meta: &api::ConnectionMeta,
8038 event: &api::AckRangeReceived,
8039 ) {
8040 (self.0).on_ack_range_received(&mut context.0, meta, event);
8041 (self.1).on_ack_range_received(&mut context.1, meta, event);
8042 }
8043 #[inline]
8044 fn on_ack_range_sent(
8045 &mut self,
8046 context: &mut Self::ConnectionContext,
8047 meta: &api::ConnectionMeta,
8048 event: &api::AckRangeSent,
8049 ) {
8050 (self.0).on_ack_range_sent(&mut context.0, meta, event);
8051 (self.1).on_ack_range_sent(&mut context.1, meta, event);
8052 }
8053 #[inline]
8054 fn on_packet_dropped(
8055 &mut self,
8056 context: &mut Self::ConnectionContext,
8057 meta: &api::ConnectionMeta,
8058 event: &api::PacketDropped,
8059 ) {
8060 (self.0).on_packet_dropped(&mut context.0, meta, event);
8061 (self.1).on_packet_dropped(&mut context.1, meta, event);
8062 }
8063 #[inline]
8064 fn on_key_update(
8065 &mut self,
8066 context: &mut Self::ConnectionContext,
8067 meta: &api::ConnectionMeta,
8068 event: &api::KeyUpdate,
8069 ) {
8070 (self.0).on_key_update(&mut context.0, meta, event);
8071 (self.1).on_key_update(&mut context.1, meta, event);
8072 }
8073 #[inline]
8074 fn on_key_space_discarded(
8075 &mut self,
8076 context: &mut Self::ConnectionContext,
8077 meta: &api::ConnectionMeta,
8078 event: &api::KeySpaceDiscarded,
8079 ) {
8080 (self.0).on_key_space_discarded(&mut context.0, meta, event);
8081 (self.1).on_key_space_discarded(&mut context.1, meta, event);
8082 }
8083 #[inline]
8084 fn on_connection_started(
8085 &mut self,
8086 context: &mut Self::ConnectionContext,
8087 meta: &api::ConnectionMeta,
8088 event: &api::ConnectionStarted,
8089 ) {
8090 (self.0).on_connection_started(&mut context.0, meta, event);
8091 (self.1).on_connection_started(&mut context.1, meta, event);
8092 }
8093 #[inline]
8094 fn on_duplicate_packet(
8095 &mut self,
8096 context: &mut Self::ConnectionContext,
8097 meta: &api::ConnectionMeta,
8098 event: &api::DuplicatePacket,
8099 ) {
8100 (self.0).on_duplicate_packet(&mut context.0, meta, event);
8101 (self.1).on_duplicate_packet(&mut context.1, meta, event);
8102 }
8103 #[inline]
8104 fn on_transport_parameters_received(
8105 &mut self,
8106 context: &mut Self::ConnectionContext,
8107 meta: &api::ConnectionMeta,
8108 event: &api::TransportParametersReceived,
8109 ) {
8110 (self.0).on_transport_parameters_received(&mut context.0, meta, event);
8111 (self.1).on_transport_parameters_received(&mut context.1, meta, event);
8112 }
8113 #[inline]
8114 fn on_datagram_sent(
8115 &mut self,
8116 context: &mut Self::ConnectionContext,
8117 meta: &api::ConnectionMeta,
8118 event: &api::DatagramSent,
8119 ) {
8120 (self.0).on_datagram_sent(&mut context.0, meta, event);
8121 (self.1).on_datagram_sent(&mut context.1, meta, event);
8122 }
8123 #[inline]
8124 fn on_datagram_received(
8125 &mut self,
8126 context: &mut Self::ConnectionContext,
8127 meta: &api::ConnectionMeta,
8128 event: &api::DatagramReceived,
8129 ) {
8130 (self.0).on_datagram_received(&mut context.0, meta, event);
8131 (self.1).on_datagram_received(&mut context.1, meta, event);
8132 }
8133 #[inline]
8134 fn on_datagram_dropped(
8135 &mut self,
8136 context: &mut Self::ConnectionContext,
8137 meta: &api::ConnectionMeta,
8138 event: &api::DatagramDropped,
8139 ) {
8140 (self.0).on_datagram_dropped(&mut context.0, meta, event);
8141 (self.1).on_datagram_dropped(&mut context.1, meta, event);
8142 }
8143 #[inline]
8144 fn on_handshake_remote_address_change_observed(
8145 &mut self,
8146 context: &mut Self::ConnectionContext,
8147 meta: &api::ConnectionMeta,
8148 event: &api::HandshakeRemoteAddressChangeObserved,
8149 ) {
8150 (self.0).on_handshake_remote_address_change_observed(&mut context.0, meta, event);
8151 (self.1).on_handshake_remote_address_change_observed(&mut context.1, meta, event);
8152 }
8153 #[inline]
8154 fn on_connection_id_updated(
8155 &mut self,
8156 context: &mut Self::ConnectionContext,
8157 meta: &api::ConnectionMeta,
8158 event: &api::ConnectionIdUpdated,
8159 ) {
8160 (self.0).on_connection_id_updated(&mut context.0, meta, event);
8161 (self.1).on_connection_id_updated(&mut context.1, meta, event);
8162 }
8163 #[inline]
8164 fn on_ecn_state_changed(
8165 &mut self,
8166 context: &mut Self::ConnectionContext,
8167 meta: &api::ConnectionMeta,
8168 event: &api::EcnStateChanged,
8169 ) {
8170 (self.0).on_ecn_state_changed(&mut context.0, meta, event);
8171 (self.1).on_ecn_state_changed(&mut context.1, meta, event);
8172 }
8173 #[inline]
8174 fn on_connection_migration_denied(
8175 &mut self,
8176 context: &mut Self::ConnectionContext,
8177 meta: &api::ConnectionMeta,
8178 event: &api::ConnectionMigrationDenied,
8179 ) {
8180 (self.0).on_connection_migration_denied(&mut context.0, meta, event);
8181 (self.1).on_connection_migration_denied(&mut context.1, meta, event);
8182 }
8183 #[inline]
8184 fn on_handshake_status_updated(
8185 &mut self,
8186 context: &mut Self::ConnectionContext,
8187 meta: &api::ConnectionMeta,
8188 event: &api::HandshakeStatusUpdated,
8189 ) {
8190 (self.0).on_handshake_status_updated(&mut context.0, meta, event);
8191 (self.1).on_handshake_status_updated(&mut context.1, meta, event);
8192 }
8193 #[inline]
8194 fn on_tls_exporter_ready(
8195 &mut self,
8196 context: &mut Self::ConnectionContext,
8197 meta: &api::ConnectionMeta,
8198 event: &api::TlsExporterReady,
8199 ) {
8200 (self.0).on_tls_exporter_ready(&mut context.0, meta, event);
8201 (self.1).on_tls_exporter_ready(&mut context.1, meta, event);
8202 }
8203 #[inline]
8204 fn on_tls_handshake_failed(
8205 &mut self,
8206 context: &mut Self::ConnectionContext,
8207 meta: &api::ConnectionMeta,
8208 event: &api::TlsHandshakeFailed,
8209 ) {
8210 (self.0).on_tls_handshake_failed(&mut context.0, meta, event);
8211 (self.1).on_tls_handshake_failed(&mut context.1, meta, event);
8212 }
8213 #[inline]
8214 fn on_path_challenge_updated(
8215 &mut self,
8216 context: &mut Self::ConnectionContext,
8217 meta: &api::ConnectionMeta,
8218 event: &api::PathChallengeUpdated,
8219 ) {
8220 (self.0).on_path_challenge_updated(&mut context.0, meta, event);
8221 (self.1).on_path_challenge_updated(&mut context.1, meta, event);
8222 }
8223 #[inline]
8224 fn on_tls_client_hello(
8225 &mut self,
8226 context: &mut Self::ConnectionContext,
8227 meta: &api::ConnectionMeta,
8228 event: &api::TlsClientHello,
8229 ) {
8230 (self.0).on_tls_client_hello(&mut context.0, meta, event);
8231 (self.1).on_tls_client_hello(&mut context.1, meta, event);
8232 }
8233 #[inline]
8234 fn on_tls_server_hello(
8235 &mut self,
8236 context: &mut Self::ConnectionContext,
8237 meta: &api::ConnectionMeta,
8238 event: &api::TlsServerHello,
8239 ) {
8240 (self.0).on_tls_server_hello(&mut context.0, meta, event);
8241 (self.1).on_tls_server_hello(&mut context.1, meta, event);
8242 }
8243 #[inline]
8244 fn on_rx_stream_progress(
8245 &mut self,
8246 context: &mut Self::ConnectionContext,
8247 meta: &api::ConnectionMeta,
8248 event: &api::RxStreamProgress,
8249 ) {
8250 (self.0).on_rx_stream_progress(&mut context.0, meta, event);
8251 (self.1).on_rx_stream_progress(&mut context.1, meta, event);
8252 }
8253 #[inline]
8254 fn on_tx_stream_progress(
8255 &mut self,
8256 context: &mut Self::ConnectionContext,
8257 meta: &api::ConnectionMeta,
8258 event: &api::TxStreamProgress,
8259 ) {
8260 (self.0).on_tx_stream_progress(&mut context.0, meta, event);
8261 (self.1).on_tx_stream_progress(&mut context.1, meta, event);
8262 }
8263 #[inline]
8264 fn on_keep_alive_timer_expired(
8265 &mut self,
8266 context: &mut Self::ConnectionContext,
8267 meta: &api::ConnectionMeta,
8268 event: &api::KeepAliveTimerExpired,
8269 ) {
8270 (self.0).on_keep_alive_timer_expired(&mut context.0, meta, event);
8271 (self.1).on_keep_alive_timer_expired(&mut context.1, meta, event);
8272 }
8273 #[inline]
8274 fn on_mtu_updated(
8275 &mut self,
8276 context: &mut Self::ConnectionContext,
8277 meta: &api::ConnectionMeta,
8278 event: &api::MtuUpdated,
8279 ) {
8280 (self.0).on_mtu_updated(&mut context.0, meta, event);
8281 (self.1).on_mtu_updated(&mut context.1, meta, event);
8282 }
8283 #[inline]
8284 fn on_slow_start_exited(
8285 &mut self,
8286 context: &mut Self::ConnectionContext,
8287 meta: &api::ConnectionMeta,
8288 event: &api::SlowStartExited,
8289 ) {
8290 (self.0).on_slow_start_exited(&mut context.0, meta, event);
8291 (self.1).on_slow_start_exited(&mut context.1, meta, event);
8292 }
8293 #[inline]
8294 fn on_delivery_rate_sampled(
8295 &mut self,
8296 context: &mut Self::ConnectionContext,
8297 meta: &api::ConnectionMeta,
8298 event: &api::DeliveryRateSampled,
8299 ) {
8300 (self.0).on_delivery_rate_sampled(&mut context.0, meta, event);
8301 (self.1).on_delivery_rate_sampled(&mut context.1, meta, event);
8302 }
8303 #[inline]
8304 fn on_pacing_rate_updated(
8305 &mut self,
8306 context: &mut Self::ConnectionContext,
8307 meta: &api::ConnectionMeta,
8308 event: &api::PacingRateUpdated,
8309 ) {
8310 (self.0).on_pacing_rate_updated(&mut context.0, meta, event);
8311 (self.1).on_pacing_rate_updated(&mut context.1, meta, event);
8312 }
8313 #[inline]
8314 fn on_bbr_state_changed(
8315 &mut self,
8316 context: &mut Self::ConnectionContext,
8317 meta: &api::ConnectionMeta,
8318 event: &api::BbrStateChanged,
8319 ) {
8320 (self.0).on_bbr_state_changed(&mut context.0, meta, event);
8321 (self.1).on_bbr_state_changed(&mut context.1, meta, event);
8322 }
8323 #[inline]
8324 fn on_dc_state_changed(
8325 &mut self,
8326 context: &mut Self::ConnectionContext,
8327 meta: &api::ConnectionMeta,
8328 event: &api::DcStateChanged,
8329 ) {
8330 (self.0).on_dc_state_changed(&mut context.0, meta, event);
8331 (self.1).on_dc_state_changed(&mut context.1, meta, event);
8332 }
8333 #[inline]
8334 fn on_dc_path_created(
8335 &mut self,
8336 context: &mut Self::ConnectionContext,
8337 meta: &api::ConnectionMeta,
8338 event: &api::DcPathCreated,
8339 ) {
8340 (self.0).on_dc_path_created(&mut context.0, meta, event);
8341 (self.1).on_dc_path_created(&mut context.1, meta, event);
8342 }
8343 #[inline]
8344 fn on_connection_closed(
8345 &mut self,
8346 context: &mut Self::ConnectionContext,
8347 meta: &api::ConnectionMeta,
8348 event: &api::ConnectionClosed,
8349 ) {
8350 (self.0).on_connection_closed(&mut context.0, meta, event);
8351 (self.1).on_connection_closed(&mut context.1, meta, event);
8352 }
8353 #[inline]
8354 fn on_version_information(
8355 &mut self,
8356 meta: &api::EndpointMeta,
8357 event: &api::VersionInformation,
8358 ) {
8359 (self.0).on_version_information(meta, event);
8360 (self.1).on_version_information(meta, event);
8361 }
8362 #[inline]
8363 fn on_endpoint_packet_sent(
8364 &mut self,
8365 meta: &api::EndpointMeta,
8366 event: &api::EndpointPacketSent,
8367 ) {
8368 (self.0).on_endpoint_packet_sent(meta, event);
8369 (self.1).on_endpoint_packet_sent(meta, event);
8370 }
8371 #[inline]
8372 fn on_endpoint_packet_received(
8373 &mut self,
8374 meta: &api::EndpointMeta,
8375 event: &api::EndpointPacketReceived,
8376 ) {
8377 (self.0).on_endpoint_packet_received(meta, event);
8378 (self.1).on_endpoint_packet_received(meta, event);
8379 }
8380 #[inline]
8381 fn on_endpoint_datagram_sent(
8382 &mut self,
8383 meta: &api::EndpointMeta,
8384 event: &api::EndpointDatagramSent,
8385 ) {
8386 (self.0).on_endpoint_datagram_sent(meta, event);
8387 (self.1).on_endpoint_datagram_sent(meta, event);
8388 }
8389 #[inline]
8390 fn on_endpoint_datagram_received(
8391 &mut self,
8392 meta: &api::EndpointMeta,
8393 event: &api::EndpointDatagramReceived,
8394 ) {
8395 (self.0).on_endpoint_datagram_received(meta, event);
8396 (self.1).on_endpoint_datagram_received(meta, event);
8397 }
8398 #[inline]
8399 fn on_endpoint_datagram_dropped(
8400 &mut self,
8401 meta: &api::EndpointMeta,
8402 event: &api::EndpointDatagramDropped,
8403 ) {
8404 (self.0).on_endpoint_datagram_dropped(meta, event);
8405 (self.1).on_endpoint_datagram_dropped(meta, event);
8406 }
8407 #[inline]
8408 fn on_endpoint_connection_attempt_failed(
8409 &mut self,
8410 meta: &api::EndpointMeta,
8411 event: &api::EndpointConnectionAttemptFailed,
8412 ) {
8413 (self.0).on_endpoint_connection_attempt_failed(meta, event);
8414 (self.1).on_endpoint_connection_attempt_failed(meta, event);
8415 }
8416 #[inline]
8417 fn on_endpoint_connection_attempt_deduplicated(
8418 &mut self,
8419 meta: &api::EndpointMeta,
8420 event: &api::EndpointConnectionAttemptDeduplicated,
8421 ) {
8422 (self.0).on_endpoint_connection_attempt_deduplicated(meta, event);
8423 (self.1).on_endpoint_connection_attempt_deduplicated(meta, event);
8424 }
8425 #[inline]
8426 fn on_platform_tx(&mut self, meta: &api::EndpointMeta, event: &api::PlatformTx) {
8427 (self.0).on_platform_tx(meta, event);
8428 (self.1).on_platform_tx(meta, event);
8429 }
8430 #[inline]
8431 fn on_platform_tx_error(&mut self, meta: &api::EndpointMeta, event: &api::PlatformTxError) {
8432 (self.0).on_platform_tx_error(meta, event);
8433 (self.1).on_platform_tx_error(meta, event);
8434 }
8435 #[inline]
8436 fn on_platform_rx(&mut self, meta: &api::EndpointMeta, event: &api::PlatformRx) {
8437 (self.0).on_platform_rx(meta, event);
8438 (self.1).on_platform_rx(meta, event);
8439 }
8440 #[inline]
8441 fn on_platform_rx_error(&mut self, meta: &api::EndpointMeta, event: &api::PlatformRxError) {
8442 (self.0).on_platform_rx_error(meta, event);
8443 (self.1).on_platform_rx_error(meta, event);
8444 }
8445 #[inline]
8446 fn on_platform_feature_configured(
8447 &mut self,
8448 meta: &api::EndpointMeta,
8449 event: &api::PlatformFeatureConfigured,
8450 ) {
8451 (self.0).on_platform_feature_configured(meta, event);
8452 (self.1).on_platform_feature_configured(meta, event);
8453 }
8454 #[inline]
8455 fn on_platform_event_loop_wakeup(
8456 &mut self,
8457 meta: &api::EndpointMeta,
8458 event: &api::PlatformEventLoopWakeup,
8459 ) {
8460 (self.0).on_platform_event_loop_wakeup(meta, event);
8461 (self.1).on_platform_event_loop_wakeup(meta, event);
8462 }
8463 #[inline]
8464 fn on_platform_event_loop_sleep(
8465 &mut self,
8466 meta: &api::EndpointMeta,
8467 event: &api::PlatformEventLoopSleep,
8468 ) {
8469 (self.0).on_platform_event_loop_sleep(meta, event);
8470 (self.1).on_platform_event_loop_sleep(meta, event);
8471 }
8472 #[inline]
8473 fn on_platform_event_loop_started(
8474 &mut self,
8475 meta: &api::EndpointMeta,
8476 event: &api::PlatformEventLoopStarted,
8477 ) {
8478 (self.0).on_platform_event_loop_started(meta, event);
8479 (self.1).on_platform_event_loop_started(meta, event);
8480 }
8481 #[inline]
8482 fn on_event<M: Meta, E: Event>(&mut self, meta: &M, event: &E) {
8483 self.0.on_event(meta, event);
8484 self.1.on_event(meta, event);
8485 }
8486 #[inline]
8487 fn on_connection_event<E: Event>(
8488 &mut self,
8489 context: &mut Self::ConnectionContext,
8490 meta: &api::ConnectionMeta,
8491 event: &E,
8492 ) {
8493 self.0.on_connection_event(&mut context.0, meta, event);
8494 self.1.on_connection_event(&mut context.1, meta, event);
8495 }
8496 #[inline]
8497 fn query(
8498 context: &Self::ConnectionContext,
8499 query: &mut dyn query::Query,
8500 ) -> query::ControlFlow {
8501 query
8502 .execute(context)
8503 .and_then(|| A::query(&context.0, query))
8504 .and_then(|| B::query(&context.1, query))
8505 }
8506 #[inline]
8507 fn query_mut(
8508 context: &mut Self::ConnectionContext,
8509 query: &mut dyn query::QueryMut,
8510 ) -> query::ControlFlow {
8511 query
8512 .execute_mut(context)
8513 .and_then(|| A::query_mut(&mut context.0, query))
8514 .and_then(|| B::query_mut(&mut context.1, query))
8515 }
8516 }
8517 pub trait EndpointPublisher {
8518 #[doc = "Publishes a `VersionInformation` event to the publisher's subscriber"]
8519 fn on_version_information(&mut self, event: builder::VersionInformation);
8520 #[doc = "Publishes a `EndpointPacketSent` event to the publisher's subscriber"]
8521 fn on_endpoint_packet_sent(&mut self, event: builder::EndpointPacketSent);
8522 #[doc = "Publishes a `EndpointPacketReceived` event to the publisher's subscriber"]
8523 fn on_endpoint_packet_received(&mut self, event: builder::EndpointPacketReceived);
8524 #[doc = "Publishes a `EndpointDatagramSent` event to the publisher's subscriber"]
8525 fn on_endpoint_datagram_sent(&mut self, event: builder::EndpointDatagramSent);
8526 #[doc = "Publishes a `EndpointDatagramReceived` event to the publisher's subscriber"]
8527 fn on_endpoint_datagram_received(&mut self, event: builder::EndpointDatagramReceived);
8528 #[doc = "Publishes a `EndpointDatagramDropped` event to the publisher's subscriber"]
8529 fn on_endpoint_datagram_dropped(&mut self, event: builder::EndpointDatagramDropped);
8530 #[doc = "Publishes a `EndpointConnectionAttemptFailed` event to the publisher's subscriber"]
8531 fn on_endpoint_connection_attempt_failed(
8532 &mut self,
8533 event: builder::EndpointConnectionAttemptFailed,
8534 );
8535 #[doc = "Publishes a `EndpointConnectionAttemptDeduplicated` event to the publisher's subscriber"]
8536 fn on_endpoint_connection_attempt_deduplicated(
8537 &mut self,
8538 event: builder::EndpointConnectionAttemptDeduplicated,
8539 );
8540 #[doc = "Publishes a `PlatformTx` event to the publisher's subscriber"]
8541 fn on_platform_tx(&mut self, event: builder::PlatformTx);
8542 #[doc = "Publishes a `PlatformTxError` event to the publisher's subscriber"]
8543 fn on_platform_tx_error(&mut self, event: builder::PlatformTxError);
8544 #[doc = "Publishes a `PlatformRx` event to the publisher's subscriber"]
8545 fn on_platform_rx(&mut self, event: builder::PlatformRx);
8546 #[doc = "Publishes a `PlatformRxError` event to the publisher's subscriber"]
8547 fn on_platform_rx_error(&mut self, event: builder::PlatformRxError);
8548 #[doc = "Publishes a `PlatformFeatureConfigured` event to the publisher's subscriber"]
8549 fn on_platform_feature_configured(&mut self, event: builder::PlatformFeatureConfigured);
8550 #[doc = "Publishes a `PlatformEventLoopWakeup` event to the publisher's subscriber"]
8551 fn on_platform_event_loop_wakeup(&mut self, event: builder::PlatformEventLoopWakeup);
8552 #[doc = "Publishes a `PlatformEventLoopSleep` event to the publisher's subscriber"]
8553 fn on_platform_event_loop_sleep(&mut self, event: builder::PlatformEventLoopSleep);
8554 #[doc = "Publishes a `PlatformEventLoopStarted` event to the publisher's subscriber"]
8555 fn on_platform_event_loop_started(&mut self, event: builder::PlatformEventLoopStarted);
8556 #[doc = r" Returns the QUIC version, if any"]
8557 fn quic_version(&self) -> Option<u32>;
8558 }
8559 pub struct EndpointPublisherSubscriber<'a, Sub: Subscriber> {
8560 meta: api::EndpointMeta,
8561 quic_version: Option<u32>,
8562 subscriber: &'a mut Sub,
8563 }
8564 impl<'a, Sub: Subscriber> fmt::Debug for EndpointPublisherSubscriber<'a, Sub> {
8565 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
8566 f.debug_struct("ConnectionPublisherSubscriber")
8567 .field("meta", &self.meta)
8568 .field("quic_version", &self.quic_version)
8569 .finish()
8570 }
8571 }
8572 impl<'a, Sub: Subscriber> EndpointPublisherSubscriber<'a, Sub> {
8573 #[inline]
8574 pub fn new(
8575 meta: builder::EndpointMeta,
8576 quic_version: Option<u32>,
8577 subscriber: &'a mut Sub,
8578 ) -> Self {
8579 Self {
8580 meta: meta.into_event(),
8581 quic_version,
8582 subscriber,
8583 }
8584 }
8585 }
8586 impl<'a, Sub: Subscriber> EndpointPublisher for EndpointPublisherSubscriber<'a, Sub> {
8587 #[inline]
8588 fn on_version_information(&mut self, event: builder::VersionInformation) {
8589 let event = event.into_event();
8590 self.subscriber.on_version_information(&self.meta, &event);
8591 self.subscriber.on_event(&self.meta, &event);
8592 }
8593 #[inline]
8594 fn on_endpoint_packet_sent(&mut self, event: builder::EndpointPacketSent) {
8595 let event = event.into_event();
8596 self.subscriber.on_endpoint_packet_sent(&self.meta, &event);
8597 self.subscriber.on_event(&self.meta, &event);
8598 }
8599 #[inline]
8600 fn on_endpoint_packet_received(&mut self, event: builder::EndpointPacketReceived) {
8601 let event = event.into_event();
8602 self.subscriber
8603 .on_endpoint_packet_received(&self.meta, &event);
8604 self.subscriber.on_event(&self.meta, &event);
8605 }
8606 #[inline]
8607 fn on_endpoint_datagram_sent(&mut self, event: builder::EndpointDatagramSent) {
8608 let event = event.into_event();
8609 self.subscriber
8610 .on_endpoint_datagram_sent(&self.meta, &event);
8611 self.subscriber.on_event(&self.meta, &event);
8612 }
8613 #[inline]
8614 fn on_endpoint_datagram_received(&mut self, event: builder::EndpointDatagramReceived) {
8615 let event = event.into_event();
8616 self.subscriber
8617 .on_endpoint_datagram_received(&self.meta, &event);
8618 self.subscriber.on_event(&self.meta, &event);
8619 }
8620 #[inline]
8621 fn on_endpoint_datagram_dropped(&mut self, event: builder::EndpointDatagramDropped) {
8622 let event = event.into_event();
8623 self.subscriber
8624 .on_endpoint_datagram_dropped(&self.meta, &event);
8625 self.subscriber.on_event(&self.meta, &event);
8626 }
8627 #[inline]
8628 fn on_endpoint_connection_attempt_failed(
8629 &mut self,
8630 event: builder::EndpointConnectionAttemptFailed,
8631 ) {
8632 let event = event.into_event();
8633 self.subscriber
8634 .on_endpoint_connection_attempt_failed(&self.meta, &event);
8635 self.subscriber.on_event(&self.meta, &event);
8636 }
8637 #[inline]
8638 fn on_endpoint_connection_attempt_deduplicated(
8639 &mut self,
8640 event: builder::EndpointConnectionAttemptDeduplicated,
8641 ) {
8642 let event = event.into_event();
8643 self.subscriber
8644 .on_endpoint_connection_attempt_deduplicated(&self.meta, &event);
8645 self.subscriber.on_event(&self.meta, &event);
8646 }
8647 #[inline]
8648 fn on_platform_tx(&mut self, event: builder::PlatformTx) {
8649 let event = event.into_event();
8650 self.subscriber.on_platform_tx(&self.meta, &event);
8651 self.subscriber.on_event(&self.meta, &event);
8652 }
8653 #[inline]
8654 fn on_platform_tx_error(&mut self, event: builder::PlatformTxError) {
8655 let event = event.into_event();
8656 self.subscriber.on_platform_tx_error(&self.meta, &event);
8657 self.subscriber.on_event(&self.meta, &event);
8658 }
8659 #[inline]
8660 fn on_platform_rx(&mut self, event: builder::PlatformRx) {
8661 let event = event.into_event();
8662 self.subscriber.on_platform_rx(&self.meta, &event);
8663 self.subscriber.on_event(&self.meta, &event);
8664 }
8665 #[inline]
8666 fn on_platform_rx_error(&mut self, event: builder::PlatformRxError) {
8667 let event = event.into_event();
8668 self.subscriber.on_platform_rx_error(&self.meta, &event);
8669 self.subscriber.on_event(&self.meta, &event);
8670 }
8671 #[inline]
8672 fn on_platform_feature_configured(&mut self, event: builder::PlatformFeatureConfigured) {
8673 let event = event.into_event();
8674 self.subscriber
8675 .on_platform_feature_configured(&self.meta, &event);
8676 self.subscriber.on_event(&self.meta, &event);
8677 }
8678 #[inline]
8679 fn on_platform_event_loop_wakeup(&mut self, event: builder::PlatformEventLoopWakeup) {
8680 let event = event.into_event();
8681 self.subscriber
8682 .on_platform_event_loop_wakeup(&self.meta, &event);
8683 self.subscriber.on_event(&self.meta, &event);
8684 }
8685 #[inline]
8686 fn on_platform_event_loop_sleep(&mut self, event: builder::PlatformEventLoopSleep) {
8687 let event = event.into_event();
8688 self.subscriber
8689 .on_platform_event_loop_sleep(&self.meta, &event);
8690 self.subscriber.on_event(&self.meta, &event);
8691 }
8692 #[inline]
8693 fn on_platform_event_loop_started(&mut self, event: builder::PlatformEventLoopStarted) {
8694 let event = event.into_event();
8695 self.subscriber
8696 .on_platform_event_loop_started(&self.meta, &event);
8697 self.subscriber.on_event(&self.meta, &event);
8698 }
8699 #[inline]
8700 fn quic_version(&self) -> Option<u32> {
8701 self.quic_version
8702 }
8703 }
8704 pub trait ConnectionPublisher {
8705 #[doc = "Publishes a `ApplicationProtocolInformation` event to the publisher's subscriber"]
8706 fn on_application_protocol_information(
8707 &mut self,
8708 event: builder::ApplicationProtocolInformation,
8709 );
8710 #[doc = "Publishes a `ServerNameInformation` event to the publisher's subscriber"]
8711 fn on_server_name_information(&mut self, event: builder::ServerNameInformation);
8712 #[doc = "Publishes a `KeyExchangeGroup` event to the publisher's subscriber"]
8713 fn on_key_exchange_group(&mut self, event: builder::KeyExchangeGroup);
8714 #[doc = "Publishes a `PacketSkipped` event to the publisher's subscriber"]
8715 fn on_packet_skipped(&mut self, event: builder::PacketSkipped);
8716 #[doc = "Publishes a `PacketSent` event to the publisher's subscriber"]
8717 fn on_packet_sent(&mut self, event: builder::PacketSent);
8718 #[doc = "Publishes a `PacketReceived` event to the publisher's subscriber"]
8719 fn on_packet_received(&mut self, event: builder::PacketReceived);
8720 #[doc = "Publishes a `ActivePathUpdated` event to the publisher's subscriber"]
8721 fn on_active_path_updated(&mut self, event: builder::ActivePathUpdated);
8722 #[doc = "Publishes a `PathCreated` event to the publisher's subscriber"]
8723 fn on_path_created(&mut self, event: builder::PathCreated);
8724 #[doc = "Publishes a `FrameSent` event to the publisher's subscriber"]
8725 fn on_frame_sent(&mut self, event: builder::FrameSent);
8726 #[doc = "Publishes a `FrameReceived` event to the publisher's subscriber"]
8727 fn on_frame_received(&mut self, event: builder::FrameReceived);
8728 #[doc = "Publishes a `ConnectionCloseFrameReceived` event to the publisher's subscriber"]
8729 fn on_connection_close_frame_received(
8730 &mut self,
8731 event: builder::ConnectionCloseFrameReceived,
8732 );
8733 #[doc = "Publishes a `PacketLost` event to the publisher's subscriber"]
8734 fn on_packet_lost(&mut self, event: builder::PacketLost);
8735 #[doc = "Publishes a `RecoveryMetrics` event to the publisher's subscriber"]
8736 fn on_recovery_metrics(&mut self, event: builder::RecoveryMetrics);
8737 #[doc = "Publishes a `Congestion` event to the publisher's subscriber"]
8738 fn on_congestion(&mut self, event: builder::Congestion);
8739 #[doc = "Publishes a `AckProcessed` event to the publisher's subscriber"]
8740 fn on_ack_processed(&mut self, event: builder::AckProcessed);
8741 #[doc = "Publishes a `RxAckRangeDropped` event to the publisher's subscriber"]
8742 fn on_rx_ack_range_dropped(&mut self, event: builder::RxAckRangeDropped);
8743 #[doc = "Publishes a `AckRangeReceived` event to the publisher's subscriber"]
8744 fn on_ack_range_received(&mut self, event: builder::AckRangeReceived);
8745 #[doc = "Publishes a `AckRangeSent` event to the publisher's subscriber"]
8746 fn on_ack_range_sent(&mut self, event: builder::AckRangeSent);
8747 #[doc = "Publishes a `PacketDropped` event to the publisher's subscriber"]
8748 fn on_packet_dropped(&mut self, event: builder::PacketDropped);
8749 #[doc = "Publishes a `KeyUpdate` event to the publisher's subscriber"]
8750 fn on_key_update(&mut self, event: builder::KeyUpdate);
8751 #[doc = "Publishes a `KeySpaceDiscarded` event to the publisher's subscriber"]
8752 fn on_key_space_discarded(&mut self, event: builder::KeySpaceDiscarded);
8753 #[doc = "Publishes a `ConnectionStarted` event to the publisher's subscriber"]
8754 fn on_connection_started(&mut self, event: builder::ConnectionStarted);
8755 #[doc = "Publishes a `DuplicatePacket` event to the publisher's subscriber"]
8756 fn on_duplicate_packet(&mut self, event: builder::DuplicatePacket);
8757 #[doc = "Publishes a `TransportParametersReceived` event to the publisher's subscriber"]
8758 fn on_transport_parameters_received(&mut self, event: builder::TransportParametersReceived);
8759 #[doc = "Publishes a `DatagramSent` event to the publisher's subscriber"]
8760 fn on_datagram_sent(&mut self, event: builder::DatagramSent);
8761 #[doc = "Publishes a `DatagramReceived` event to the publisher's subscriber"]
8762 fn on_datagram_received(&mut self, event: builder::DatagramReceived);
8763 #[doc = "Publishes a `DatagramDropped` event to the publisher's subscriber"]
8764 fn on_datagram_dropped(&mut self, event: builder::DatagramDropped);
8765 #[doc = "Publishes a `HandshakeRemoteAddressChangeObserved` event to the publisher's subscriber"]
8766 fn on_handshake_remote_address_change_observed(
8767 &mut self,
8768 event: builder::HandshakeRemoteAddressChangeObserved,
8769 );
8770 #[doc = "Publishes a `ConnectionIdUpdated` event to the publisher's subscriber"]
8771 fn on_connection_id_updated(&mut self, event: builder::ConnectionIdUpdated);
8772 #[doc = "Publishes a `EcnStateChanged` event to the publisher's subscriber"]
8773 fn on_ecn_state_changed(&mut self, event: builder::EcnStateChanged);
8774 #[doc = "Publishes a `ConnectionMigrationDenied` event to the publisher's subscriber"]
8775 fn on_connection_migration_denied(&mut self, event: builder::ConnectionMigrationDenied);
8776 #[doc = "Publishes a `HandshakeStatusUpdated` event to the publisher's subscriber"]
8777 fn on_handshake_status_updated(&mut self, event: builder::HandshakeStatusUpdated);
8778 #[doc = "Publishes a `TlsExporterReady` event to the publisher's subscriber"]
8779 fn on_tls_exporter_ready(&mut self, event: builder::TlsExporterReady);
8780 #[doc = "Publishes a `TlsHandshakeFailed` event to the publisher's subscriber"]
8781 fn on_tls_handshake_failed(&mut self, event: builder::TlsHandshakeFailed);
8782 #[doc = "Publishes a `PathChallengeUpdated` event to the publisher's subscriber"]
8783 fn on_path_challenge_updated(&mut self, event: builder::PathChallengeUpdated);
8784 #[doc = "Publishes a `TlsClientHello` event to the publisher's subscriber"]
8785 fn on_tls_client_hello(&mut self, event: builder::TlsClientHello);
8786 #[doc = "Publishes a `TlsServerHello` event to the publisher's subscriber"]
8787 fn on_tls_server_hello(&mut self, event: builder::TlsServerHello);
8788 #[doc = "Publishes a `RxStreamProgress` event to the publisher's subscriber"]
8789 fn on_rx_stream_progress(&mut self, event: builder::RxStreamProgress);
8790 #[doc = "Publishes a `TxStreamProgress` event to the publisher's subscriber"]
8791 fn on_tx_stream_progress(&mut self, event: builder::TxStreamProgress);
8792 #[doc = "Publishes a `KeepAliveTimerExpired` event to the publisher's subscriber"]
8793 fn on_keep_alive_timer_expired(&mut self, event: builder::KeepAliveTimerExpired);
8794 #[doc = "Publishes a `MtuUpdated` event to the publisher's subscriber"]
8795 fn on_mtu_updated(&mut self, event: builder::MtuUpdated);
8796 #[doc = "Publishes a `SlowStartExited` event to the publisher's subscriber"]
8797 fn on_slow_start_exited(&mut self, event: builder::SlowStartExited);
8798 #[doc = "Publishes a `DeliveryRateSampled` event to the publisher's subscriber"]
8799 fn on_delivery_rate_sampled(&mut self, event: builder::DeliveryRateSampled);
8800 #[doc = "Publishes a `PacingRateUpdated` event to the publisher's subscriber"]
8801 fn on_pacing_rate_updated(&mut self, event: builder::PacingRateUpdated);
8802 #[doc = "Publishes a `BbrStateChanged` event to the publisher's subscriber"]
8803 fn on_bbr_state_changed(&mut self, event: builder::BbrStateChanged);
8804 #[doc = "Publishes a `DcStateChanged` event to the publisher's subscriber"]
8805 fn on_dc_state_changed(&mut self, event: builder::DcStateChanged);
8806 #[doc = "Publishes a `DcPathCreated` event to the publisher's subscriber"]
8807 fn on_dc_path_created(&mut self, event: builder::DcPathCreated);
8808 #[doc = "Publishes a `ConnectionClosed` event to the publisher's subscriber"]
8809 fn on_connection_closed(&mut self, event: builder::ConnectionClosed);
8810 #[doc = r" Returns the QUIC version negotiated for the current connection, if any"]
8811 fn quic_version(&self) -> u32;
8812 #[doc = r" Returns the [`Subject`] for the current publisher"]
8813 fn subject(&self) -> api::Subject;
8814 }
8815 pub struct ConnectionPublisherSubscriber<'a, Sub: Subscriber> {
8816 meta: api::ConnectionMeta,
8817 quic_version: u32,
8818 subscriber: &'a mut Sub,
8819 context: &'a mut Sub::ConnectionContext,
8820 }
8821 impl<'a, Sub: Subscriber> fmt::Debug for ConnectionPublisherSubscriber<'a, Sub> {
8822 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
8823 f.debug_struct("ConnectionPublisherSubscriber")
8824 .field("meta", &self.meta)
8825 .field("quic_version", &self.quic_version)
8826 .finish()
8827 }
8828 }
8829 impl<'a, Sub: Subscriber> ConnectionPublisherSubscriber<'a, Sub> {
8830 #[inline]
8831 pub fn new(
8832 meta: builder::ConnectionMeta,
8833 quic_version: u32,
8834 subscriber: &'a mut Sub,
8835 context: &'a mut Sub::ConnectionContext,
8836 ) -> Self {
8837 Self {
8838 meta: meta.into_event(),
8839 quic_version,
8840 subscriber,
8841 context,
8842 }
8843 }
8844 }
8845 impl<'a, Sub: Subscriber> ConnectionPublisher for ConnectionPublisherSubscriber<'a, Sub> {
8846 #[inline]
8847 fn on_application_protocol_information(
8848 &mut self,
8849 event: builder::ApplicationProtocolInformation,
8850 ) {
8851 let event = event.into_event();
8852 self.subscriber
8853 .on_application_protocol_information(self.context, &self.meta, &event);
8854 self.subscriber
8855 .on_connection_event(self.context, &self.meta, &event);
8856 self.subscriber.on_event(&self.meta, &event);
8857 }
8858 #[inline]
8859 fn on_server_name_information(&mut self, event: builder::ServerNameInformation) {
8860 let event = event.into_event();
8861 self.subscriber
8862 .on_server_name_information(self.context, &self.meta, &event);
8863 self.subscriber
8864 .on_connection_event(self.context, &self.meta, &event);
8865 self.subscriber.on_event(&self.meta, &event);
8866 }
8867 #[inline]
8868 fn on_key_exchange_group(&mut self, event: builder::KeyExchangeGroup) {
8869 let event = event.into_event();
8870 self.subscriber
8871 .on_key_exchange_group(self.context, &self.meta, &event);
8872 self.subscriber
8873 .on_connection_event(self.context, &self.meta, &event);
8874 self.subscriber.on_event(&self.meta, &event);
8875 }
8876 #[inline]
8877 fn on_packet_skipped(&mut self, event: builder::PacketSkipped) {
8878 let event = event.into_event();
8879 self.subscriber
8880 .on_packet_skipped(self.context, &self.meta, &event);
8881 self.subscriber
8882 .on_connection_event(self.context, &self.meta, &event);
8883 self.subscriber.on_event(&self.meta, &event);
8884 }
8885 #[inline]
8886 fn on_packet_sent(&mut self, event: builder::PacketSent) {
8887 let event = event.into_event();
8888 self.subscriber
8889 .on_packet_sent(self.context, &self.meta, &event);
8890 self.subscriber
8891 .on_connection_event(self.context, &self.meta, &event);
8892 self.subscriber.on_event(&self.meta, &event);
8893 }
8894 #[inline]
8895 fn on_packet_received(&mut self, event: builder::PacketReceived) {
8896 let event = event.into_event();
8897 self.subscriber
8898 .on_packet_received(self.context, &self.meta, &event);
8899 self.subscriber
8900 .on_connection_event(self.context, &self.meta, &event);
8901 self.subscriber.on_event(&self.meta, &event);
8902 }
8903 #[inline]
8904 fn on_active_path_updated(&mut self, event: builder::ActivePathUpdated) {
8905 let event = event.into_event();
8906 self.subscriber
8907 .on_active_path_updated(self.context, &self.meta, &event);
8908 self.subscriber
8909 .on_connection_event(self.context, &self.meta, &event);
8910 self.subscriber.on_event(&self.meta, &event);
8911 }
8912 #[inline]
8913 fn on_path_created(&mut self, event: builder::PathCreated) {
8914 let event = event.into_event();
8915 self.subscriber
8916 .on_path_created(self.context, &self.meta, &event);
8917 self.subscriber
8918 .on_connection_event(self.context, &self.meta, &event);
8919 self.subscriber.on_event(&self.meta, &event);
8920 }
8921 #[inline]
8922 fn on_frame_sent(&mut self, event: builder::FrameSent) {
8923 let event = event.into_event();
8924 self.subscriber
8925 .on_frame_sent(self.context, &self.meta, &event);
8926 self.subscriber
8927 .on_connection_event(self.context, &self.meta, &event);
8928 self.subscriber.on_event(&self.meta, &event);
8929 }
8930 #[inline]
8931 fn on_frame_received(&mut self, event: builder::FrameReceived) {
8932 let event = event.into_event();
8933 self.subscriber
8934 .on_frame_received(self.context, &self.meta, &event);
8935 self.subscriber
8936 .on_connection_event(self.context, &self.meta, &event);
8937 self.subscriber.on_event(&self.meta, &event);
8938 }
8939 #[inline]
8940 fn on_connection_close_frame_received(
8941 &mut self,
8942 event: builder::ConnectionCloseFrameReceived,
8943 ) {
8944 let event = event.into_event();
8945 self.subscriber
8946 .on_connection_close_frame_received(self.context, &self.meta, &event);
8947 self.subscriber
8948 .on_connection_event(self.context, &self.meta, &event);
8949 self.subscriber.on_event(&self.meta, &event);
8950 }
8951 #[inline]
8952 fn on_packet_lost(&mut self, event: builder::PacketLost) {
8953 let event = event.into_event();
8954 self.subscriber
8955 .on_packet_lost(self.context, &self.meta, &event);
8956 self.subscriber
8957 .on_connection_event(self.context, &self.meta, &event);
8958 self.subscriber.on_event(&self.meta, &event);
8959 }
8960 #[inline]
8961 fn on_recovery_metrics(&mut self, event: builder::RecoveryMetrics) {
8962 let event = event.into_event();
8963 self.subscriber
8964 .on_recovery_metrics(self.context, &self.meta, &event);
8965 self.subscriber
8966 .on_connection_event(self.context, &self.meta, &event);
8967 self.subscriber.on_event(&self.meta, &event);
8968 }
8969 #[inline]
8970 fn on_congestion(&mut self, event: builder::Congestion) {
8971 let event = event.into_event();
8972 self.subscriber
8973 .on_congestion(self.context, &self.meta, &event);
8974 self.subscriber
8975 .on_connection_event(self.context, &self.meta, &event);
8976 self.subscriber.on_event(&self.meta, &event);
8977 }
8978 #[inline]
8979 #[allow(deprecated)]
8980 fn on_ack_processed(&mut self, event: builder::AckProcessed) {
8981 let event = event.into_event();
8982 self.subscriber
8983 .on_ack_processed(self.context, &self.meta, &event);
8984 self.subscriber
8985 .on_connection_event(self.context, &self.meta, &event);
8986 self.subscriber.on_event(&self.meta, &event);
8987 }
8988 #[inline]
8989 fn on_rx_ack_range_dropped(&mut self, event: builder::RxAckRangeDropped) {
8990 let event = event.into_event();
8991 self.subscriber
8992 .on_rx_ack_range_dropped(self.context, &self.meta, &event);
8993 self.subscriber
8994 .on_connection_event(self.context, &self.meta, &event);
8995 self.subscriber.on_event(&self.meta, &event);
8996 }
8997 #[inline]
8998 fn on_ack_range_received(&mut self, event: builder::AckRangeReceived) {
8999 let event = event.into_event();
9000 self.subscriber
9001 .on_ack_range_received(self.context, &self.meta, &event);
9002 self.subscriber
9003 .on_connection_event(self.context, &self.meta, &event);
9004 self.subscriber.on_event(&self.meta, &event);
9005 }
9006 #[inline]
9007 fn on_ack_range_sent(&mut self, event: builder::AckRangeSent) {
9008 let event = event.into_event();
9009 self.subscriber
9010 .on_ack_range_sent(self.context, &self.meta, &event);
9011 self.subscriber
9012 .on_connection_event(self.context, &self.meta, &event);
9013 self.subscriber.on_event(&self.meta, &event);
9014 }
9015 #[inline]
9016 fn on_packet_dropped(&mut self, event: builder::PacketDropped) {
9017 let event = event.into_event();
9018 self.subscriber
9019 .on_packet_dropped(self.context, &self.meta, &event);
9020 self.subscriber
9021 .on_connection_event(self.context, &self.meta, &event);
9022 self.subscriber.on_event(&self.meta, &event);
9023 }
9024 #[inline]
9025 fn on_key_update(&mut self, event: builder::KeyUpdate) {
9026 let event = event.into_event();
9027 self.subscriber
9028 .on_key_update(self.context, &self.meta, &event);
9029 self.subscriber
9030 .on_connection_event(self.context, &self.meta, &event);
9031 self.subscriber.on_event(&self.meta, &event);
9032 }
9033 #[inline]
9034 fn on_key_space_discarded(&mut self, event: builder::KeySpaceDiscarded) {
9035 let event = event.into_event();
9036 self.subscriber
9037 .on_key_space_discarded(self.context, &self.meta, &event);
9038 self.subscriber
9039 .on_connection_event(self.context, &self.meta, &event);
9040 self.subscriber.on_event(&self.meta, &event);
9041 }
9042 #[inline]
9043 fn on_connection_started(&mut self, event: builder::ConnectionStarted) {
9044 let event = event.into_event();
9045 self.subscriber
9046 .on_connection_started(self.context, &self.meta, &event);
9047 self.subscriber
9048 .on_connection_event(self.context, &self.meta, &event);
9049 self.subscriber.on_event(&self.meta, &event);
9050 }
9051 #[inline]
9052 fn on_duplicate_packet(&mut self, event: builder::DuplicatePacket) {
9053 let event = event.into_event();
9054 self.subscriber
9055 .on_duplicate_packet(self.context, &self.meta, &event);
9056 self.subscriber
9057 .on_connection_event(self.context, &self.meta, &event);
9058 self.subscriber.on_event(&self.meta, &event);
9059 }
9060 #[inline]
9061 fn on_transport_parameters_received(
9062 &mut self,
9063 event: builder::TransportParametersReceived,
9064 ) {
9065 let event = event.into_event();
9066 self.subscriber
9067 .on_transport_parameters_received(self.context, &self.meta, &event);
9068 self.subscriber
9069 .on_connection_event(self.context, &self.meta, &event);
9070 self.subscriber.on_event(&self.meta, &event);
9071 }
9072 #[inline]
9073 fn on_datagram_sent(&mut self, event: builder::DatagramSent) {
9074 let event = event.into_event();
9075 self.subscriber
9076 .on_datagram_sent(self.context, &self.meta, &event);
9077 self.subscriber
9078 .on_connection_event(self.context, &self.meta, &event);
9079 self.subscriber.on_event(&self.meta, &event);
9080 }
9081 #[inline]
9082 fn on_datagram_received(&mut self, event: builder::DatagramReceived) {
9083 let event = event.into_event();
9084 self.subscriber
9085 .on_datagram_received(self.context, &self.meta, &event);
9086 self.subscriber
9087 .on_connection_event(self.context, &self.meta, &event);
9088 self.subscriber.on_event(&self.meta, &event);
9089 }
9090 #[inline]
9091 fn on_datagram_dropped(&mut self, event: builder::DatagramDropped) {
9092 let event = event.into_event();
9093 self.subscriber
9094 .on_datagram_dropped(self.context, &self.meta, &event);
9095 self.subscriber
9096 .on_connection_event(self.context, &self.meta, &event);
9097 self.subscriber.on_event(&self.meta, &event);
9098 }
9099 #[inline]
9100 fn on_handshake_remote_address_change_observed(
9101 &mut self,
9102 event: builder::HandshakeRemoteAddressChangeObserved,
9103 ) {
9104 let event = event.into_event();
9105 self.subscriber.on_handshake_remote_address_change_observed(
9106 self.context,
9107 &self.meta,
9108 &event,
9109 );
9110 self.subscriber
9111 .on_connection_event(self.context, &self.meta, &event);
9112 self.subscriber.on_event(&self.meta, &event);
9113 }
9114 #[inline]
9115 fn on_connection_id_updated(&mut self, event: builder::ConnectionIdUpdated) {
9116 let event = event.into_event();
9117 self.subscriber
9118 .on_connection_id_updated(self.context, &self.meta, &event);
9119 self.subscriber
9120 .on_connection_event(self.context, &self.meta, &event);
9121 self.subscriber.on_event(&self.meta, &event);
9122 }
9123 #[inline]
9124 fn on_ecn_state_changed(&mut self, event: builder::EcnStateChanged) {
9125 let event = event.into_event();
9126 self.subscriber
9127 .on_ecn_state_changed(self.context, &self.meta, &event);
9128 self.subscriber
9129 .on_connection_event(self.context, &self.meta, &event);
9130 self.subscriber.on_event(&self.meta, &event);
9131 }
9132 #[inline]
9133 fn on_connection_migration_denied(&mut self, event: builder::ConnectionMigrationDenied) {
9134 let event = event.into_event();
9135 self.subscriber
9136 .on_connection_migration_denied(self.context, &self.meta, &event);
9137 self.subscriber
9138 .on_connection_event(self.context, &self.meta, &event);
9139 self.subscriber.on_event(&self.meta, &event);
9140 }
9141 #[inline]
9142 fn on_handshake_status_updated(&mut self, event: builder::HandshakeStatusUpdated) {
9143 let event = event.into_event();
9144 self.subscriber
9145 .on_handshake_status_updated(self.context, &self.meta, &event);
9146 self.subscriber
9147 .on_connection_event(self.context, &self.meta, &event);
9148 self.subscriber.on_event(&self.meta, &event);
9149 }
9150 #[inline]
9151 fn on_tls_exporter_ready(&mut self, event: builder::TlsExporterReady) {
9152 let event = event.into_event();
9153 self.subscriber
9154 .on_tls_exporter_ready(self.context, &self.meta, &event);
9155 self.subscriber
9156 .on_connection_event(self.context, &self.meta, &event);
9157 self.subscriber.on_event(&self.meta, &event);
9158 }
9159 #[inline]
9160 fn on_tls_handshake_failed(&mut self, event: builder::TlsHandshakeFailed) {
9161 let event = event.into_event();
9162 self.subscriber
9163 .on_tls_handshake_failed(self.context, &self.meta, &event);
9164 self.subscriber
9165 .on_connection_event(self.context, &self.meta, &event);
9166 self.subscriber.on_event(&self.meta, &event);
9167 }
9168 #[inline]
9169 fn on_path_challenge_updated(&mut self, event: builder::PathChallengeUpdated) {
9170 let event = event.into_event();
9171 self.subscriber
9172 .on_path_challenge_updated(self.context, &self.meta, &event);
9173 self.subscriber
9174 .on_connection_event(self.context, &self.meta, &event);
9175 self.subscriber.on_event(&self.meta, &event);
9176 }
9177 #[inline]
9178 fn on_tls_client_hello(&mut self, event: builder::TlsClientHello) {
9179 let event = event.into_event();
9180 self.subscriber
9181 .on_tls_client_hello(self.context, &self.meta, &event);
9182 self.subscriber
9183 .on_connection_event(self.context, &self.meta, &event);
9184 self.subscriber.on_event(&self.meta, &event);
9185 }
9186 #[inline]
9187 fn on_tls_server_hello(&mut self, event: builder::TlsServerHello) {
9188 let event = event.into_event();
9189 self.subscriber
9190 .on_tls_server_hello(self.context, &self.meta, &event);
9191 self.subscriber
9192 .on_connection_event(self.context, &self.meta, &event);
9193 self.subscriber.on_event(&self.meta, &event);
9194 }
9195 #[inline]
9196 fn on_rx_stream_progress(&mut self, event: builder::RxStreamProgress) {
9197 let event = event.into_event();
9198 self.subscriber
9199 .on_rx_stream_progress(self.context, &self.meta, &event);
9200 self.subscriber
9201 .on_connection_event(self.context, &self.meta, &event);
9202 self.subscriber.on_event(&self.meta, &event);
9203 }
9204 #[inline]
9205 fn on_tx_stream_progress(&mut self, event: builder::TxStreamProgress) {
9206 let event = event.into_event();
9207 self.subscriber
9208 .on_tx_stream_progress(self.context, &self.meta, &event);
9209 self.subscriber
9210 .on_connection_event(self.context, &self.meta, &event);
9211 self.subscriber.on_event(&self.meta, &event);
9212 }
9213 #[inline]
9214 fn on_keep_alive_timer_expired(&mut self, event: builder::KeepAliveTimerExpired) {
9215 let event = event.into_event();
9216 self.subscriber
9217 .on_keep_alive_timer_expired(self.context, &self.meta, &event);
9218 self.subscriber
9219 .on_connection_event(self.context, &self.meta, &event);
9220 self.subscriber.on_event(&self.meta, &event);
9221 }
9222 #[inline]
9223 fn on_mtu_updated(&mut self, event: builder::MtuUpdated) {
9224 let event = event.into_event();
9225 self.subscriber
9226 .on_mtu_updated(self.context, &self.meta, &event);
9227 self.subscriber
9228 .on_connection_event(self.context, &self.meta, &event);
9229 self.subscriber.on_event(&self.meta, &event);
9230 }
9231 #[inline]
9232 fn on_slow_start_exited(&mut self, event: builder::SlowStartExited) {
9233 let event = event.into_event();
9234 self.subscriber
9235 .on_slow_start_exited(self.context, &self.meta, &event);
9236 self.subscriber
9237 .on_connection_event(self.context, &self.meta, &event);
9238 self.subscriber.on_event(&self.meta, &event);
9239 }
9240 #[inline]
9241 fn on_delivery_rate_sampled(&mut self, event: builder::DeliveryRateSampled) {
9242 let event = event.into_event();
9243 self.subscriber
9244 .on_delivery_rate_sampled(self.context, &self.meta, &event);
9245 self.subscriber
9246 .on_connection_event(self.context, &self.meta, &event);
9247 self.subscriber.on_event(&self.meta, &event);
9248 }
9249 #[inline]
9250 fn on_pacing_rate_updated(&mut self, event: builder::PacingRateUpdated) {
9251 let event = event.into_event();
9252 self.subscriber
9253 .on_pacing_rate_updated(self.context, &self.meta, &event);
9254 self.subscriber
9255 .on_connection_event(self.context, &self.meta, &event);
9256 self.subscriber.on_event(&self.meta, &event);
9257 }
9258 #[inline]
9259 fn on_bbr_state_changed(&mut self, event: builder::BbrStateChanged) {
9260 let event = event.into_event();
9261 self.subscriber
9262 .on_bbr_state_changed(self.context, &self.meta, &event);
9263 self.subscriber
9264 .on_connection_event(self.context, &self.meta, &event);
9265 self.subscriber.on_event(&self.meta, &event);
9266 }
9267 #[inline]
9268 fn on_dc_state_changed(&mut self, event: builder::DcStateChanged) {
9269 let event = event.into_event();
9270 self.subscriber
9271 .on_dc_state_changed(self.context, &self.meta, &event);
9272 self.subscriber
9273 .on_connection_event(self.context, &self.meta, &event);
9274 self.subscriber.on_event(&self.meta, &event);
9275 }
9276 #[inline]
9277 fn on_dc_path_created(&mut self, event: builder::DcPathCreated) {
9278 let event = event.into_event();
9279 self.subscriber
9280 .on_dc_path_created(self.context, &self.meta, &event);
9281 self.subscriber
9282 .on_connection_event(self.context, &self.meta, &event);
9283 self.subscriber.on_event(&self.meta, &event);
9284 }
9285 #[inline]
9286 fn on_connection_closed(&mut self, event: builder::ConnectionClosed) {
9287 let event = event.into_event();
9288 self.subscriber
9289 .on_connection_closed(self.context, &self.meta, &event);
9290 self.subscriber
9291 .on_connection_event(self.context, &self.meta, &event);
9292 self.subscriber.on_event(&self.meta, &event);
9293 }
9294 #[inline]
9295 fn quic_version(&self) -> u32 {
9296 self.quic_version
9297 }
9298 #[inline]
9299 fn subject(&self) -> api::Subject {
9300 self.meta.subject()
9301 }
9302 }
9303}
9304#[cfg(any(test, feature = "testing"))]
9305pub mod testing {
9306 use super::*;
9307 use crate::event::snapshot::Location;
9308 pub mod endpoint {
9309 use super::*;
9310 pub struct Subscriber {
9311 location: Option<Location>,
9312 output: Vec<String>,
9313 pub version_information: u64,
9314 pub endpoint_packet_sent: u64,
9315 pub endpoint_packet_received: u64,
9316 pub endpoint_datagram_sent: u64,
9317 pub endpoint_datagram_received: u64,
9318 pub endpoint_datagram_dropped: u64,
9319 pub endpoint_connection_attempt_failed: u64,
9320 pub endpoint_connection_attempt_deduplicated: u64,
9321 pub platform_tx: u64,
9322 pub platform_tx_error: u64,
9323 pub platform_rx: u64,
9324 pub platform_rx_error: u64,
9325 pub platform_feature_configured: u64,
9326 pub platform_event_loop_wakeup: u64,
9327 pub platform_event_loop_sleep: u64,
9328 pub platform_event_loop_started: u64,
9329 }
9330 impl Drop for Subscriber {
9331 fn drop(&mut self) {
9332 if std::thread::panicking() {
9333 return;
9334 }
9335 if let Some(location) = self.location.as_ref() {
9336 location.snapshot_log(&self.output);
9337 }
9338 }
9339 }
9340 impl Subscriber {
9341 #[doc = r" Creates a subscriber with snapshot assertions enabled"]
9342 #[track_caller]
9343 pub fn snapshot() -> Self {
9344 let mut sub = Self::no_snapshot();
9345 sub.location = Location::from_thread_name();
9346 sub
9347 }
9348 #[doc = r" Creates a subscriber with snapshot assertions enabled"]
9349 #[track_caller]
9350 pub fn named_snapshot<Name: core::fmt::Display>(name: Name) -> Self {
9351 let mut sub = Self::no_snapshot();
9352 sub.location = Some(Location::new(name));
9353 sub
9354 }
9355 #[doc = r" Creates a subscriber with snapshot assertions disabled"]
9356 pub fn no_snapshot() -> Self {
9357 Self {
9358 location: None,
9359 output: Default::default(),
9360 version_information: 0,
9361 endpoint_packet_sent: 0,
9362 endpoint_packet_received: 0,
9363 endpoint_datagram_sent: 0,
9364 endpoint_datagram_received: 0,
9365 endpoint_datagram_dropped: 0,
9366 endpoint_connection_attempt_failed: 0,
9367 endpoint_connection_attempt_deduplicated: 0,
9368 platform_tx: 0,
9369 platform_tx_error: 0,
9370 platform_rx: 0,
9371 platform_rx_error: 0,
9372 platform_feature_configured: 0,
9373 platform_event_loop_wakeup: 0,
9374 platform_event_loop_sleep: 0,
9375 platform_event_loop_started: 0,
9376 }
9377 }
9378 }
9379 impl super::super::Subscriber for Subscriber {
9380 type ConnectionContext = ();
9381 fn create_connection_context(
9382 &mut self,
9383 _meta: &api::ConnectionMeta,
9384 _info: &api::ConnectionInfo,
9385 ) -> Self::ConnectionContext {
9386 }
9387 fn on_version_information(
9388 &mut self,
9389 meta: &api::EndpointMeta,
9390 event: &api::VersionInformation,
9391 ) {
9392 self.version_information += 1;
9393 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9394 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9395 let out = format!("{meta:?} {event:?}");
9396 self.output.push(out);
9397 }
9398 fn on_endpoint_packet_sent(
9399 &mut self,
9400 meta: &api::EndpointMeta,
9401 event: &api::EndpointPacketSent,
9402 ) {
9403 self.endpoint_packet_sent += 1;
9404 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9405 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9406 let out = format!("{meta:?} {event:?}");
9407 self.output.push(out);
9408 }
9409 fn on_endpoint_packet_received(
9410 &mut self,
9411 meta: &api::EndpointMeta,
9412 event: &api::EndpointPacketReceived,
9413 ) {
9414 self.endpoint_packet_received += 1;
9415 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9416 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9417 let out = format!("{meta:?} {event:?}");
9418 self.output.push(out);
9419 }
9420 fn on_endpoint_datagram_sent(
9421 &mut self,
9422 meta: &api::EndpointMeta,
9423 event: &api::EndpointDatagramSent,
9424 ) {
9425 self.endpoint_datagram_sent += 1;
9426 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9427 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9428 let out = format!("{meta:?} {event:?}");
9429 self.output.push(out);
9430 }
9431 fn on_endpoint_datagram_received(
9432 &mut self,
9433 meta: &api::EndpointMeta,
9434 event: &api::EndpointDatagramReceived,
9435 ) {
9436 self.endpoint_datagram_received += 1;
9437 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9438 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9439 let out = format!("{meta:?} {event:?}");
9440 self.output.push(out);
9441 }
9442 fn on_endpoint_datagram_dropped(
9443 &mut self,
9444 meta: &api::EndpointMeta,
9445 event: &api::EndpointDatagramDropped,
9446 ) {
9447 self.endpoint_datagram_dropped += 1;
9448 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9449 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9450 let out = format!("{meta:?} {event:?}");
9451 self.output.push(out);
9452 }
9453 fn on_endpoint_connection_attempt_failed(
9454 &mut self,
9455 meta: &api::EndpointMeta,
9456 event: &api::EndpointConnectionAttemptFailed,
9457 ) {
9458 self.endpoint_connection_attempt_failed += 1;
9459 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9460 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9461 let out = format!("{meta:?} {event:?}");
9462 self.output.push(out);
9463 }
9464 fn on_endpoint_connection_attempt_deduplicated(
9465 &mut self,
9466 meta: &api::EndpointMeta,
9467 event: &api::EndpointConnectionAttemptDeduplicated,
9468 ) {
9469 self.endpoint_connection_attempt_deduplicated += 1;
9470 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9471 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9472 let out = format!("{meta:?} {event:?}");
9473 self.output.push(out);
9474 }
9475 fn on_platform_tx(&mut self, meta: &api::EndpointMeta, event: &api::PlatformTx) {
9476 self.platform_tx += 1;
9477 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9478 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9479 let out = format!("{meta:?} {event:?}");
9480 self.output.push(out);
9481 }
9482 fn on_platform_tx_error(
9483 &mut self,
9484 meta: &api::EndpointMeta,
9485 event: &api::PlatformTxError,
9486 ) {
9487 self.platform_tx_error += 1;
9488 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9489 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9490 let out = format!("{meta:?} {event:?}");
9491 self.output.push(out);
9492 }
9493 fn on_platform_rx(&mut self, meta: &api::EndpointMeta, event: &api::PlatformRx) {
9494 self.platform_rx += 1;
9495 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9496 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9497 let out = format!("{meta:?} {event:?}");
9498 self.output.push(out);
9499 }
9500 fn on_platform_rx_error(
9501 &mut self,
9502 meta: &api::EndpointMeta,
9503 event: &api::PlatformRxError,
9504 ) {
9505 self.platform_rx_error += 1;
9506 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9507 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9508 let out = format!("{meta:?} {event:?}");
9509 self.output.push(out);
9510 }
9511 fn on_platform_feature_configured(
9512 &mut self,
9513 meta: &api::EndpointMeta,
9514 event: &api::PlatformFeatureConfigured,
9515 ) {
9516 self.platform_feature_configured += 1;
9517 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9518 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9519 let out = format!("{meta:?} {event:?}");
9520 self.output.push(out);
9521 }
9522 fn on_platform_event_loop_wakeup(
9523 &mut self,
9524 meta: &api::EndpointMeta,
9525 event: &api::PlatformEventLoopWakeup,
9526 ) {
9527 self.platform_event_loop_wakeup += 1;
9528 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9529 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9530 let out = format!("{meta:?} {event:?}");
9531 self.output.push(out);
9532 }
9533 fn on_platform_event_loop_sleep(
9534 &mut self,
9535 meta: &api::EndpointMeta,
9536 event: &api::PlatformEventLoopSleep,
9537 ) {
9538 self.platform_event_loop_sleep += 1;
9539 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9540 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9541 let out = format!("{meta:?} {event:?}");
9542 self.output.push(out);
9543 }
9544 fn on_platform_event_loop_started(
9545 &mut self,
9546 meta: &api::EndpointMeta,
9547 event: &api::PlatformEventLoopStarted,
9548 ) {
9549 self.platform_event_loop_started += 1;
9550 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9551 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9552 let out = format!("{meta:?} {event:?}");
9553 self.output.push(out);
9554 }
9555 }
9556 }
9557 #[derive(Debug)]
9558 pub struct Subscriber {
9559 location: Option<Location>,
9560 output: Vec<String>,
9561 pub application_protocol_information: u64,
9562 pub server_name_information: u64,
9563 pub key_exchange_group: u64,
9564 pub packet_skipped: u64,
9565 pub packet_sent: u64,
9566 pub packet_received: u64,
9567 pub active_path_updated: u64,
9568 pub path_created: u64,
9569 pub frame_sent: u64,
9570 pub frame_received: u64,
9571 pub connection_close_frame_received: u64,
9572 pub packet_lost: u64,
9573 pub recovery_metrics: u64,
9574 pub congestion: u64,
9575 pub ack_processed: u64,
9576 pub rx_ack_range_dropped: u64,
9577 pub ack_range_received: u64,
9578 pub ack_range_sent: u64,
9579 pub packet_dropped: u64,
9580 pub key_update: u64,
9581 pub key_space_discarded: u64,
9582 pub connection_started: u64,
9583 pub duplicate_packet: u64,
9584 pub transport_parameters_received: u64,
9585 pub datagram_sent: u64,
9586 pub datagram_received: u64,
9587 pub datagram_dropped: u64,
9588 pub handshake_remote_address_change_observed: u64,
9589 pub connection_id_updated: u64,
9590 pub ecn_state_changed: u64,
9591 pub connection_migration_denied: u64,
9592 pub handshake_status_updated: u64,
9593 pub tls_exporter_ready: u64,
9594 pub tls_handshake_failed: u64,
9595 pub path_challenge_updated: u64,
9596 pub tls_client_hello: u64,
9597 pub tls_server_hello: u64,
9598 pub rx_stream_progress: u64,
9599 pub tx_stream_progress: u64,
9600 pub keep_alive_timer_expired: u64,
9601 pub mtu_updated: u64,
9602 pub slow_start_exited: u64,
9603 pub delivery_rate_sampled: u64,
9604 pub pacing_rate_updated: u64,
9605 pub bbr_state_changed: u64,
9606 pub dc_state_changed: u64,
9607 pub dc_path_created: u64,
9608 pub connection_closed: u64,
9609 pub version_information: u64,
9610 pub endpoint_packet_sent: u64,
9611 pub endpoint_packet_received: u64,
9612 pub endpoint_datagram_sent: u64,
9613 pub endpoint_datagram_received: u64,
9614 pub endpoint_datagram_dropped: u64,
9615 pub endpoint_connection_attempt_failed: u64,
9616 pub endpoint_connection_attempt_deduplicated: u64,
9617 pub platform_tx: u64,
9618 pub platform_tx_error: u64,
9619 pub platform_rx: u64,
9620 pub platform_rx_error: u64,
9621 pub platform_feature_configured: u64,
9622 pub platform_event_loop_wakeup: u64,
9623 pub platform_event_loop_sleep: u64,
9624 pub platform_event_loop_started: u64,
9625 }
9626 impl Drop for Subscriber {
9627 fn drop(&mut self) {
9628 if std::thread::panicking() {
9629 return;
9630 }
9631 if let Some(location) = self.location.as_ref() {
9632 location.snapshot_log(&self.output);
9633 }
9634 }
9635 }
9636 impl Subscriber {
9637 #[doc = r" Creates a subscriber with snapshot assertions enabled"]
9638 #[track_caller]
9639 pub fn snapshot() -> Self {
9640 let mut sub = Self::no_snapshot();
9641 sub.location = Location::from_thread_name();
9642 sub
9643 }
9644 #[doc = r" Creates a subscriber with snapshot assertions enabled"]
9645 #[track_caller]
9646 pub fn named_snapshot<Name: core::fmt::Display>(name: Name) -> Self {
9647 let mut sub = Self::no_snapshot();
9648 sub.location = Some(Location::new(name));
9649 sub
9650 }
9651 #[doc = r" Creates a subscriber with snapshot assertions disabled"]
9652 pub fn no_snapshot() -> Self {
9653 Self {
9654 location: None,
9655 output: Default::default(),
9656 application_protocol_information: 0,
9657 server_name_information: 0,
9658 key_exchange_group: 0,
9659 packet_skipped: 0,
9660 packet_sent: 0,
9661 packet_received: 0,
9662 active_path_updated: 0,
9663 path_created: 0,
9664 frame_sent: 0,
9665 frame_received: 0,
9666 connection_close_frame_received: 0,
9667 packet_lost: 0,
9668 recovery_metrics: 0,
9669 congestion: 0,
9670 ack_processed: 0,
9671 rx_ack_range_dropped: 0,
9672 ack_range_received: 0,
9673 ack_range_sent: 0,
9674 packet_dropped: 0,
9675 key_update: 0,
9676 key_space_discarded: 0,
9677 connection_started: 0,
9678 duplicate_packet: 0,
9679 transport_parameters_received: 0,
9680 datagram_sent: 0,
9681 datagram_received: 0,
9682 datagram_dropped: 0,
9683 handshake_remote_address_change_observed: 0,
9684 connection_id_updated: 0,
9685 ecn_state_changed: 0,
9686 connection_migration_denied: 0,
9687 handshake_status_updated: 0,
9688 tls_exporter_ready: 0,
9689 tls_handshake_failed: 0,
9690 path_challenge_updated: 0,
9691 tls_client_hello: 0,
9692 tls_server_hello: 0,
9693 rx_stream_progress: 0,
9694 tx_stream_progress: 0,
9695 keep_alive_timer_expired: 0,
9696 mtu_updated: 0,
9697 slow_start_exited: 0,
9698 delivery_rate_sampled: 0,
9699 pacing_rate_updated: 0,
9700 bbr_state_changed: 0,
9701 dc_state_changed: 0,
9702 dc_path_created: 0,
9703 connection_closed: 0,
9704 version_information: 0,
9705 endpoint_packet_sent: 0,
9706 endpoint_packet_received: 0,
9707 endpoint_datagram_sent: 0,
9708 endpoint_datagram_received: 0,
9709 endpoint_datagram_dropped: 0,
9710 endpoint_connection_attempt_failed: 0,
9711 endpoint_connection_attempt_deduplicated: 0,
9712 platform_tx: 0,
9713 platform_tx_error: 0,
9714 platform_rx: 0,
9715 platform_rx_error: 0,
9716 platform_feature_configured: 0,
9717 platform_event_loop_wakeup: 0,
9718 platform_event_loop_sleep: 0,
9719 platform_event_loop_started: 0,
9720 }
9721 }
9722 }
9723 impl super::Subscriber for Subscriber {
9724 type ConnectionContext = ();
9725 fn create_connection_context(
9726 &mut self,
9727 _meta: &api::ConnectionMeta,
9728 _info: &api::ConnectionInfo,
9729 ) -> Self::ConnectionContext {
9730 }
9731 fn on_application_protocol_information(
9732 &mut self,
9733 _context: &mut Self::ConnectionContext,
9734 meta: &api::ConnectionMeta,
9735 event: &api::ApplicationProtocolInformation,
9736 ) {
9737 self.application_protocol_information += 1;
9738 if self.location.is_some() {
9739 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9740 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9741 let out = format!("{meta:?} {event:?}");
9742 self.output.push(out);
9743 }
9744 }
9745 fn on_server_name_information(
9746 &mut self,
9747 _context: &mut Self::ConnectionContext,
9748 meta: &api::ConnectionMeta,
9749 event: &api::ServerNameInformation,
9750 ) {
9751 self.server_name_information += 1;
9752 if self.location.is_some() {
9753 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9754 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9755 let out = format!("{meta:?} {event:?}");
9756 self.output.push(out);
9757 }
9758 }
9759 fn on_key_exchange_group(
9760 &mut self,
9761 _context: &mut Self::ConnectionContext,
9762 meta: &api::ConnectionMeta,
9763 event: &api::KeyExchangeGroup,
9764 ) {
9765 self.key_exchange_group += 1;
9766 if self.location.is_some() {
9767 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9768 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9769 let out = format!("{meta:?} {event:?}");
9770 self.output.push(out);
9771 }
9772 }
9773 fn on_packet_skipped(
9774 &mut self,
9775 _context: &mut Self::ConnectionContext,
9776 meta: &api::ConnectionMeta,
9777 event: &api::PacketSkipped,
9778 ) {
9779 self.packet_skipped += 1;
9780 if self.location.is_some() {
9781 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9782 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9783 let out = format!("{meta:?} {event:?}");
9784 self.output.push(out);
9785 }
9786 }
9787 fn on_packet_sent(
9788 &mut self,
9789 _context: &mut Self::ConnectionContext,
9790 meta: &api::ConnectionMeta,
9791 event: &api::PacketSent,
9792 ) {
9793 self.packet_sent += 1;
9794 if self.location.is_some() {
9795 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9796 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9797 let out = format!("{meta:?} {event:?}");
9798 self.output.push(out);
9799 }
9800 }
9801 fn on_packet_received(
9802 &mut self,
9803 _context: &mut Self::ConnectionContext,
9804 meta: &api::ConnectionMeta,
9805 event: &api::PacketReceived,
9806 ) {
9807 self.packet_received += 1;
9808 if self.location.is_some() {
9809 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9810 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9811 let out = format!("{meta:?} {event:?}");
9812 self.output.push(out);
9813 }
9814 }
9815 fn on_active_path_updated(
9816 &mut self,
9817 _context: &mut Self::ConnectionContext,
9818 meta: &api::ConnectionMeta,
9819 event: &api::ActivePathUpdated,
9820 ) {
9821 self.active_path_updated += 1;
9822 if self.location.is_some() {
9823 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9824 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9825 let out = format!("{meta:?} {event:?}");
9826 self.output.push(out);
9827 }
9828 }
9829 fn on_path_created(
9830 &mut self,
9831 _context: &mut Self::ConnectionContext,
9832 meta: &api::ConnectionMeta,
9833 event: &api::PathCreated,
9834 ) {
9835 self.path_created += 1;
9836 if self.location.is_some() {
9837 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9838 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9839 let out = format!("{meta:?} {event:?}");
9840 self.output.push(out);
9841 }
9842 }
9843 fn on_frame_sent(
9844 &mut self,
9845 _context: &mut Self::ConnectionContext,
9846 meta: &api::ConnectionMeta,
9847 event: &api::FrameSent,
9848 ) {
9849 self.frame_sent += 1;
9850 if self.location.is_some() {
9851 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9852 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9853 let out = format!("{meta:?} {event:?}");
9854 self.output.push(out);
9855 }
9856 }
9857 fn on_frame_received(
9858 &mut self,
9859 _context: &mut Self::ConnectionContext,
9860 meta: &api::ConnectionMeta,
9861 event: &api::FrameReceived,
9862 ) {
9863 self.frame_received += 1;
9864 if self.location.is_some() {
9865 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9866 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9867 let out = format!("{meta:?} {event:?}");
9868 self.output.push(out);
9869 }
9870 }
9871 fn on_connection_close_frame_received(
9872 &mut self,
9873 _context: &mut Self::ConnectionContext,
9874 meta: &api::ConnectionMeta,
9875 event: &api::ConnectionCloseFrameReceived,
9876 ) {
9877 self.connection_close_frame_received += 1;
9878 if self.location.is_some() {
9879 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9880 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9881 let out = format!("{meta:?} {event:?}");
9882 self.output.push(out);
9883 }
9884 }
9885 fn on_packet_lost(
9886 &mut self,
9887 _context: &mut Self::ConnectionContext,
9888 meta: &api::ConnectionMeta,
9889 event: &api::PacketLost,
9890 ) {
9891 self.packet_lost += 1;
9892 if self.location.is_some() {
9893 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9894 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9895 let out = format!("{meta:?} {event:?}");
9896 self.output.push(out);
9897 }
9898 }
9899 fn on_recovery_metrics(
9900 &mut self,
9901 _context: &mut Self::ConnectionContext,
9902 meta: &api::ConnectionMeta,
9903 event: &api::RecoveryMetrics,
9904 ) {
9905 self.recovery_metrics += 1;
9906 if self.location.is_some() {
9907 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9908 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9909 let out = format!("{meta:?} {event:?}");
9910 self.output.push(out);
9911 }
9912 }
9913 fn on_congestion(
9914 &mut self,
9915 _context: &mut Self::ConnectionContext,
9916 meta: &api::ConnectionMeta,
9917 event: &api::Congestion,
9918 ) {
9919 self.congestion += 1;
9920 if self.location.is_some() {
9921 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9922 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9923 let out = format!("{meta:?} {event:?}");
9924 self.output.push(out);
9925 }
9926 }
9927 #[allow(deprecated)]
9928 fn on_ack_processed(
9929 &mut self,
9930 _context: &mut Self::ConnectionContext,
9931 meta: &api::ConnectionMeta,
9932 event: &api::AckProcessed,
9933 ) {
9934 self.ack_processed += 1;
9935 if self.location.is_some() {
9936 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9937 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9938 let out = format!("{meta:?} {event:?}");
9939 self.output.push(out);
9940 }
9941 }
9942 fn on_rx_ack_range_dropped(
9943 &mut self,
9944 _context: &mut Self::ConnectionContext,
9945 meta: &api::ConnectionMeta,
9946 event: &api::RxAckRangeDropped,
9947 ) {
9948 self.rx_ack_range_dropped += 1;
9949 if self.location.is_some() {
9950 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9951 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9952 let out = format!("{meta:?} {event:?}");
9953 self.output.push(out);
9954 }
9955 }
9956 fn on_ack_range_received(
9957 &mut self,
9958 _context: &mut Self::ConnectionContext,
9959 meta: &api::ConnectionMeta,
9960 event: &api::AckRangeReceived,
9961 ) {
9962 self.ack_range_received += 1;
9963 if self.location.is_some() {
9964 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9965 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9966 let out = format!("{meta:?} {event:?}");
9967 self.output.push(out);
9968 }
9969 }
9970 fn on_ack_range_sent(
9971 &mut self,
9972 _context: &mut Self::ConnectionContext,
9973 meta: &api::ConnectionMeta,
9974 event: &api::AckRangeSent,
9975 ) {
9976 self.ack_range_sent += 1;
9977 if self.location.is_some() {
9978 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9979 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9980 let out = format!("{meta:?} {event:?}");
9981 self.output.push(out);
9982 }
9983 }
9984 fn on_packet_dropped(
9985 &mut self,
9986 _context: &mut Self::ConnectionContext,
9987 meta: &api::ConnectionMeta,
9988 event: &api::PacketDropped,
9989 ) {
9990 self.packet_dropped += 1;
9991 if self.location.is_some() {
9992 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
9993 let event = crate::event::snapshot::Fmt::to_snapshot(event);
9994 let out = format!("{meta:?} {event:?}");
9995 self.output.push(out);
9996 }
9997 }
9998 fn on_key_update(
9999 &mut self,
10000 _context: &mut Self::ConnectionContext,
10001 meta: &api::ConnectionMeta,
10002 event: &api::KeyUpdate,
10003 ) {
10004 self.key_update += 1;
10005 if self.location.is_some() {
10006 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10007 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10008 let out = format!("{meta:?} {event:?}");
10009 self.output.push(out);
10010 }
10011 }
10012 fn on_key_space_discarded(
10013 &mut self,
10014 _context: &mut Self::ConnectionContext,
10015 meta: &api::ConnectionMeta,
10016 event: &api::KeySpaceDiscarded,
10017 ) {
10018 self.key_space_discarded += 1;
10019 if self.location.is_some() {
10020 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10021 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10022 let out = format!("{meta:?} {event:?}");
10023 self.output.push(out);
10024 }
10025 }
10026 fn on_connection_started(
10027 &mut self,
10028 _context: &mut Self::ConnectionContext,
10029 meta: &api::ConnectionMeta,
10030 event: &api::ConnectionStarted,
10031 ) {
10032 self.connection_started += 1;
10033 if self.location.is_some() {
10034 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10035 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10036 let out = format!("{meta:?} {event:?}");
10037 self.output.push(out);
10038 }
10039 }
10040 fn on_duplicate_packet(
10041 &mut self,
10042 _context: &mut Self::ConnectionContext,
10043 meta: &api::ConnectionMeta,
10044 event: &api::DuplicatePacket,
10045 ) {
10046 self.duplicate_packet += 1;
10047 if self.location.is_some() {
10048 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10049 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10050 let out = format!("{meta:?} {event:?}");
10051 self.output.push(out);
10052 }
10053 }
10054 fn on_transport_parameters_received(
10055 &mut self,
10056 _context: &mut Self::ConnectionContext,
10057 meta: &api::ConnectionMeta,
10058 event: &api::TransportParametersReceived,
10059 ) {
10060 self.transport_parameters_received += 1;
10061 if self.location.is_some() {
10062 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10063 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10064 let out = format!("{meta:?} {event:?}");
10065 self.output.push(out);
10066 }
10067 }
10068 fn on_datagram_sent(
10069 &mut self,
10070 _context: &mut Self::ConnectionContext,
10071 meta: &api::ConnectionMeta,
10072 event: &api::DatagramSent,
10073 ) {
10074 self.datagram_sent += 1;
10075 if self.location.is_some() {
10076 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10077 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10078 let out = format!("{meta:?} {event:?}");
10079 self.output.push(out);
10080 }
10081 }
10082 fn on_datagram_received(
10083 &mut self,
10084 _context: &mut Self::ConnectionContext,
10085 meta: &api::ConnectionMeta,
10086 event: &api::DatagramReceived,
10087 ) {
10088 self.datagram_received += 1;
10089 if self.location.is_some() {
10090 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10091 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10092 let out = format!("{meta:?} {event:?}");
10093 self.output.push(out);
10094 }
10095 }
10096 fn on_datagram_dropped(
10097 &mut self,
10098 _context: &mut Self::ConnectionContext,
10099 meta: &api::ConnectionMeta,
10100 event: &api::DatagramDropped,
10101 ) {
10102 self.datagram_dropped += 1;
10103 if self.location.is_some() {
10104 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10105 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10106 let out = format!("{meta:?} {event:?}");
10107 self.output.push(out);
10108 }
10109 }
10110 fn on_handshake_remote_address_change_observed(
10111 &mut self,
10112 _context: &mut Self::ConnectionContext,
10113 meta: &api::ConnectionMeta,
10114 event: &api::HandshakeRemoteAddressChangeObserved,
10115 ) {
10116 self.handshake_remote_address_change_observed += 1;
10117 if self.location.is_some() {
10118 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10119 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10120 let out = format!("{meta:?} {event:?}");
10121 self.output.push(out);
10122 }
10123 }
10124 fn on_connection_id_updated(
10125 &mut self,
10126 _context: &mut Self::ConnectionContext,
10127 meta: &api::ConnectionMeta,
10128 event: &api::ConnectionIdUpdated,
10129 ) {
10130 self.connection_id_updated += 1;
10131 if self.location.is_some() {
10132 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10133 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10134 let out = format!("{meta:?} {event:?}");
10135 self.output.push(out);
10136 }
10137 }
10138 fn on_ecn_state_changed(
10139 &mut self,
10140 _context: &mut Self::ConnectionContext,
10141 meta: &api::ConnectionMeta,
10142 event: &api::EcnStateChanged,
10143 ) {
10144 self.ecn_state_changed += 1;
10145 if self.location.is_some() {
10146 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10147 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10148 let out = format!("{meta:?} {event:?}");
10149 self.output.push(out);
10150 }
10151 }
10152 fn on_connection_migration_denied(
10153 &mut self,
10154 _context: &mut Self::ConnectionContext,
10155 meta: &api::ConnectionMeta,
10156 event: &api::ConnectionMigrationDenied,
10157 ) {
10158 self.connection_migration_denied += 1;
10159 if self.location.is_some() {
10160 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10161 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10162 let out = format!("{meta:?} {event:?}");
10163 self.output.push(out);
10164 }
10165 }
10166 fn on_handshake_status_updated(
10167 &mut self,
10168 _context: &mut Self::ConnectionContext,
10169 meta: &api::ConnectionMeta,
10170 event: &api::HandshakeStatusUpdated,
10171 ) {
10172 self.handshake_status_updated += 1;
10173 if self.location.is_some() {
10174 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10175 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10176 let out = format!("{meta:?} {event:?}");
10177 self.output.push(out);
10178 }
10179 }
10180 fn on_tls_exporter_ready(
10181 &mut self,
10182 _context: &mut Self::ConnectionContext,
10183 meta: &api::ConnectionMeta,
10184 event: &api::TlsExporterReady,
10185 ) {
10186 self.tls_exporter_ready += 1;
10187 if self.location.is_some() {
10188 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10189 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10190 let out = format!("{meta:?} {event:?}");
10191 self.output.push(out);
10192 }
10193 }
10194 fn on_tls_handshake_failed(
10195 &mut self,
10196 _context: &mut Self::ConnectionContext,
10197 meta: &api::ConnectionMeta,
10198 event: &api::TlsHandshakeFailed,
10199 ) {
10200 self.tls_handshake_failed += 1;
10201 if self.location.is_some() {
10202 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10203 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10204 let out = format!("{meta:?} {event:?}");
10205 self.output.push(out);
10206 }
10207 }
10208 fn on_path_challenge_updated(
10209 &mut self,
10210 _context: &mut Self::ConnectionContext,
10211 meta: &api::ConnectionMeta,
10212 event: &api::PathChallengeUpdated,
10213 ) {
10214 self.path_challenge_updated += 1;
10215 if self.location.is_some() {
10216 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10217 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10218 let out = format!("{meta:?} {event:?}");
10219 self.output.push(out);
10220 }
10221 }
10222 fn on_tls_client_hello(
10223 &mut self,
10224 _context: &mut Self::ConnectionContext,
10225 meta: &api::ConnectionMeta,
10226 event: &api::TlsClientHello,
10227 ) {
10228 self.tls_client_hello += 1;
10229 if self.location.is_some() {
10230 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10231 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10232 let out = format!("{meta:?} {event:?}");
10233 self.output.push(out);
10234 }
10235 }
10236 fn on_tls_server_hello(
10237 &mut self,
10238 _context: &mut Self::ConnectionContext,
10239 meta: &api::ConnectionMeta,
10240 event: &api::TlsServerHello,
10241 ) {
10242 self.tls_server_hello += 1;
10243 if self.location.is_some() {
10244 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10245 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10246 let out = format!("{meta:?} {event:?}");
10247 self.output.push(out);
10248 }
10249 }
10250 fn on_rx_stream_progress(
10251 &mut self,
10252 _context: &mut Self::ConnectionContext,
10253 meta: &api::ConnectionMeta,
10254 event: &api::RxStreamProgress,
10255 ) {
10256 self.rx_stream_progress += 1;
10257 if self.location.is_some() {
10258 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10259 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10260 let out = format!("{meta:?} {event:?}");
10261 self.output.push(out);
10262 }
10263 }
10264 fn on_tx_stream_progress(
10265 &mut self,
10266 _context: &mut Self::ConnectionContext,
10267 meta: &api::ConnectionMeta,
10268 event: &api::TxStreamProgress,
10269 ) {
10270 self.tx_stream_progress += 1;
10271 if self.location.is_some() {
10272 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10273 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10274 let out = format!("{meta:?} {event:?}");
10275 self.output.push(out);
10276 }
10277 }
10278 fn on_keep_alive_timer_expired(
10279 &mut self,
10280 _context: &mut Self::ConnectionContext,
10281 meta: &api::ConnectionMeta,
10282 event: &api::KeepAliveTimerExpired,
10283 ) {
10284 self.keep_alive_timer_expired += 1;
10285 if self.location.is_some() {
10286 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10287 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10288 let out = format!("{meta:?} {event:?}");
10289 self.output.push(out);
10290 }
10291 }
10292 fn on_mtu_updated(
10293 &mut self,
10294 _context: &mut Self::ConnectionContext,
10295 meta: &api::ConnectionMeta,
10296 event: &api::MtuUpdated,
10297 ) {
10298 self.mtu_updated += 1;
10299 if self.location.is_some() {
10300 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10301 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10302 let out = format!("{meta:?} {event:?}");
10303 self.output.push(out);
10304 }
10305 }
10306 fn on_slow_start_exited(
10307 &mut self,
10308 _context: &mut Self::ConnectionContext,
10309 meta: &api::ConnectionMeta,
10310 event: &api::SlowStartExited,
10311 ) {
10312 self.slow_start_exited += 1;
10313 if self.location.is_some() {
10314 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10315 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10316 let out = format!("{meta:?} {event:?}");
10317 self.output.push(out);
10318 }
10319 }
10320 fn on_delivery_rate_sampled(
10321 &mut self,
10322 _context: &mut Self::ConnectionContext,
10323 meta: &api::ConnectionMeta,
10324 event: &api::DeliveryRateSampled,
10325 ) {
10326 self.delivery_rate_sampled += 1;
10327 if self.location.is_some() {
10328 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10329 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10330 let out = format!("{meta:?} {event:?}");
10331 self.output.push(out);
10332 }
10333 }
10334 fn on_pacing_rate_updated(
10335 &mut self,
10336 _context: &mut Self::ConnectionContext,
10337 meta: &api::ConnectionMeta,
10338 event: &api::PacingRateUpdated,
10339 ) {
10340 self.pacing_rate_updated += 1;
10341 if self.location.is_some() {
10342 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10343 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10344 let out = format!("{meta:?} {event:?}");
10345 self.output.push(out);
10346 }
10347 }
10348 fn on_bbr_state_changed(
10349 &mut self,
10350 _context: &mut Self::ConnectionContext,
10351 meta: &api::ConnectionMeta,
10352 event: &api::BbrStateChanged,
10353 ) {
10354 self.bbr_state_changed += 1;
10355 if self.location.is_some() {
10356 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10357 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10358 let out = format!("{meta:?} {event:?}");
10359 self.output.push(out);
10360 }
10361 }
10362 fn on_dc_state_changed(
10363 &mut self,
10364 _context: &mut Self::ConnectionContext,
10365 meta: &api::ConnectionMeta,
10366 event: &api::DcStateChanged,
10367 ) {
10368 self.dc_state_changed += 1;
10369 if self.location.is_some() {
10370 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10371 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10372 let out = format!("{meta:?} {event:?}");
10373 self.output.push(out);
10374 }
10375 }
10376 fn on_dc_path_created(
10377 &mut self,
10378 _context: &mut Self::ConnectionContext,
10379 meta: &api::ConnectionMeta,
10380 event: &api::DcPathCreated,
10381 ) {
10382 self.dc_path_created += 1;
10383 if self.location.is_some() {
10384 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10385 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10386 let out = format!("{meta:?} {event:?}");
10387 self.output.push(out);
10388 }
10389 }
10390 fn on_connection_closed(
10391 &mut self,
10392 _context: &mut Self::ConnectionContext,
10393 meta: &api::ConnectionMeta,
10394 event: &api::ConnectionClosed,
10395 ) {
10396 self.connection_closed += 1;
10397 if self.location.is_some() {
10398 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10399 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10400 let out = format!("{meta:?} {event:?}");
10401 self.output.push(out);
10402 }
10403 }
10404 fn on_version_information(
10405 &mut self,
10406 meta: &api::EndpointMeta,
10407 event: &api::VersionInformation,
10408 ) {
10409 self.version_information += 1;
10410 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10411 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10412 let out = format!("{meta:?} {event:?}");
10413 self.output.push(out);
10414 }
10415 fn on_endpoint_packet_sent(
10416 &mut self,
10417 meta: &api::EndpointMeta,
10418 event: &api::EndpointPacketSent,
10419 ) {
10420 self.endpoint_packet_sent += 1;
10421 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10422 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10423 let out = format!("{meta:?} {event:?}");
10424 self.output.push(out);
10425 }
10426 fn on_endpoint_packet_received(
10427 &mut self,
10428 meta: &api::EndpointMeta,
10429 event: &api::EndpointPacketReceived,
10430 ) {
10431 self.endpoint_packet_received += 1;
10432 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10433 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10434 let out = format!("{meta:?} {event:?}");
10435 self.output.push(out);
10436 }
10437 fn on_endpoint_datagram_sent(
10438 &mut self,
10439 meta: &api::EndpointMeta,
10440 event: &api::EndpointDatagramSent,
10441 ) {
10442 self.endpoint_datagram_sent += 1;
10443 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10444 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10445 let out = format!("{meta:?} {event:?}");
10446 self.output.push(out);
10447 }
10448 fn on_endpoint_datagram_received(
10449 &mut self,
10450 meta: &api::EndpointMeta,
10451 event: &api::EndpointDatagramReceived,
10452 ) {
10453 self.endpoint_datagram_received += 1;
10454 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10455 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10456 let out = format!("{meta:?} {event:?}");
10457 self.output.push(out);
10458 }
10459 fn on_endpoint_datagram_dropped(
10460 &mut self,
10461 meta: &api::EndpointMeta,
10462 event: &api::EndpointDatagramDropped,
10463 ) {
10464 self.endpoint_datagram_dropped += 1;
10465 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10466 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10467 let out = format!("{meta:?} {event:?}");
10468 self.output.push(out);
10469 }
10470 fn on_endpoint_connection_attempt_failed(
10471 &mut self,
10472 meta: &api::EndpointMeta,
10473 event: &api::EndpointConnectionAttemptFailed,
10474 ) {
10475 self.endpoint_connection_attempt_failed += 1;
10476 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10477 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10478 let out = format!("{meta:?} {event:?}");
10479 self.output.push(out);
10480 }
10481 fn on_endpoint_connection_attempt_deduplicated(
10482 &mut self,
10483 meta: &api::EndpointMeta,
10484 event: &api::EndpointConnectionAttemptDeduplicated,
10485 ) {
10486 self.endpoint_connection_attempt_deduplicated += 1;
10487 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10488 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10489 let out = format!("{meta:?} {event:?}");
10490 self.output.push(out);
10491 }
10492 fn on_platform_tx(&mut self, meta: &api::EndpointMeta, event: &api::PlatformTx) {
10493 self.platform_tx += 1;
10494 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10495 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10496 let out = format!("{meta:?} {event:?}");
10497 self.output.push(out);
10498 }
10499 fn on_platform_tx_error(&mut self, meta: &api::EndpointMeta, event: &api::PlatformTxError) {
10500 self.platform_tx_error += 1;
10501 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10502 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10503 let out = format!("{meta:?} {event:?}");
10504 self.output.push(out);
10505 }
10506 fn on_platform_rx(&mut self, meta: &api::EndpointMeta, event: &api::PlatformRx) {
10507 self.platform_rx += 1;
10508 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10509 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10510 let out = format!("{meta:?} {event:?}");
10511 self.output.push(out);
10512 }
10513 fn on_platform_rx_error(&mut self, meta: &api::EndpointMeta, event: &api::PlatformRxError) {
10514 self.platform_rx_error += 1;
10515 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10516 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10517 let out = format!("{meta:?} {event:?}");
10518 self.output.push(out);
10519 }
10520 fn on_platform_feature_configured(
10521 &mut self,
10522 meta: &api::EndpointMeta,
10523 event: &api::PlatformFeatureConfigured,
10524 ) {
10525 self.platform_feature_configured += 1;
10526 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10527 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10528 let out = format!("{meta:?} {event:?}");
10529 self.output.push(out);
10530 }
10531 fn on_platform_event_loop_wakeup(
10532 &mut self,
10533 meta: &api::EndpointMeta,
10534 event: &api::PlatformEventLoopWakeup,
10535 ) {
10536 self.platform_event_loop_wakeup += 1;
10537 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10538 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10539 let out = format!("{meta:?} {event:?}");
10540 self.output.push(out);
10541 }
10542 fn on_platform_event_loop_sleep(
10543 &mut self,
10544 meta: &api::EndpointMeta,
10545 event: &api::PlatformEventLoopSleep,
10546 ) {
10547 self.platform_event_loop_sleep += 1;
10548 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10549 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10550 let out = format!("{meta:?} {event:?}");
10551 self.output.push(out);
10552 }
10553 fn on_platform_event_loop_started(
10554 &mut self,
10555 meta: &api::EndpointMeta,
10556 event: &api::PlatformEventLoopStarted,
10557 ) {
10558 self.platform_event_loop_started += 1;
10559 let meta = crate::event::snapshot::Fmt::to_snapshot(meta);
10560 let event = crate::event::snapshot::Fmt::to_snapshot(event);
10561 let out = format!("{meta:?} {event:?}");
10562 self.output.push(out);
10563 }
10564 }
10565 #[derive(Debug)]
10566 pub struct Publisher {
10567 location: Option<Location>,
10568 output: Vec<String>,
10569 pub application_protocol_information: u64,
10570 pub server_name_information: u64,
10571 pub key_exchange_group: u64,
10572 pub packet_skipped: u64,
10573 pub packet_sent: u64,
10574 pub packet_received: u64,
10575 pub active_path_updated: u64,
10576 pub path_created: u64,
10577 pub frame_sent: u64,
10578 pub frame_received: u64,
10579 pub connection_close_frame_received: u64,
10580 pub packet_lost: u64,
10581 pub recovery_metrics: u64,
10582 pub congestion: u64,
10583 pub ack_processed: u64,
10584 pub rx_ack_range_dropped: u64,
10585 pub ack_range_received: u64,
10586 pub ack_range_sent: u64,
10587 pub packet_dropped: u64,
10588 pub key_update: u64,
10589 pub key_space_discarded: u64,
10590 pub connection_started: u64,
10591 pub duplicate_packet: u64,
10592 pub transport_parameters_received: u64,
10593 pub datagram_sent: u64,
10594 pub datagram_received: u64,
10595 pub datagram_dropped: u64,
10596 pub handshake_remote_address_change_observed: u64,
10597 pub connection_id_updated: u64,
10598 pub ecn_state_changed: u64,
10599 pub connection_migration_denied: u64,
10600 pub handshake_status_updated: u64,
10601 pub tls_exporter_ready: u64,
10602 pub tls_handshake_failed: u64,
10603 pub path_challenge_updated: u64,
10604 pub tls_client_hello: u64,
10605 pub tls_server_hello: u64,
10606 pub rx_stream_progress: u64,
10607 pub tx_stream_progress: u64,
10608 pub keep_alive_timer_expired: u64,
10609 pub mtu_updated: u64,
10610 pub slow_start_exited: u64,
10611 pub delivery_rate_sampled: u64,
10612 pub pacing_rate_updated: u64,
10613 pub bbr_state_changed: u64,
10614 pub dc_state_changed: u64,
10615 pub dc_path_created: u64,
10616 pub connection_closed: u64,
10617 pub version_information: u64,
10618 pub endpoint_packet_sent: u64,
10619 pub endpoint_packet_received: u64,
10620 pub endpoint_datagram_sent: u64,
10621 pub endpoint_datagram_received: u64,
10622 pub endpoint_datagram_dropped: u64,
10623 pub endpoint_connection_attempt_failed: u64,
10624 pub endpoint_connection_attempt_deduplicated: u64,
10625 pub platform_tx: u64,
10626 pub platform_tx_error: u64,
10627 pub platform_rx: u64,
10628 pub platform_rx_error: u64,
10629 pub platform_feature_configured: u64,
10630 pub platform_event_loop_wakeup: u64,
10631 pub platform_event_loop_sleep: u64,
10632 pub platform_event_loop_started: u64,
10633 }
10634 impl Publisher {
10635 #[doc = r" Creates a publisher with snapshot assertions enabled"]
10636 #[track_caller]
10637 pub fn snapshot() -> Self {
10638 let mut sub = Self::no_snapshot();
10639 sub.location = Location::from_thread_name();
10640 sub
10641 }
10642 #[doc = r" Creates a subscriber with snapshot assertions enabled"]
10643 #[track_caller]
10644 pub fn named_snapshot<Name: core::fmt::Display>(name: Name) -> Self {
10645 let mut sub = Self::no_snapshot();
10646 sub.location = Some(Location::new(name));
10647 sub
10648 }
10649 #[doc = r" Creates a publisher with snapshot assertions disabled"]
10650 pub fn no_snapshot() -> Self {
10651 Self {
10652 location: None,
10653 output: Default::default(),
10654 application_protocol_information: 0,
10655 server_name_information: 0,
10656 key_exchange_group: 0,
10657 packet_skipped: 0,
10658 packet_sent: 0,
10659 packet_received: 0,
10660 active_path_updated: 0,
10661 path_created: 0,
10662 frame_sent: 0,
10663 frame_received: 0,
10664 connection_close_frame_received: 0,
10665 packet_lost: 0,
10666 recovery_metrics: 0,
10667 congestion: 0,
10668 ack_processed: 0,
10669 rx_ack_range_dropped: 0,
10670 ack_range_received: 0,
10671 ack_range_sent: 0,
10672 packet_dropped: 0,
10673 key_update: 0,
10674 key_space_discarded: 0,
10675 connection_started: 0,
10676 duplicate_packet: 0,
10677 transport_parameters_received: 0,
10678 datagram_sent: 0,
10679 datagram_received: 0,
10680 datagram_dropped: 0,
10681 handshake_remote_address_change_observed: 0,
10682 connection_id_updated: 0,
10683 ecn_state_changed: 0,
10684 connection_migration_denied: 0,
10685 handshake_status_updated: 0,
10686 tls_exporter_ready: 0,
10687 tls_handshake_failed: 0,
10688 path_challenge_updated: 0,
10689 tls_client_hello: 0,
10690 tls_server_hello: 0,
10691 rx_stream_progress: 0,
10692 tx_stream_progress: 0,
10693 keep_alive_timer_expired: 0,
10694 mtu_updated: 0,
10695 slow_start_exited: 0,
10696 delivery_rate_sampled: 0,
10697 pacing_rate_updated: 0,
10698 bbr_state_changed: 0,
10699 dc_state_changed: 0,
10700 dc_path_created: 0,
10701 connection_closed: 0,
10702 version_information: 0,
10703 endpoint_packet_sent: 0,
10704 endpoint_packet_received: 0,
10705 endpoint_datagram_sent: 0,
10706 endpoint_datagram_received: 0,
10707 endpoint_datagram_dropped: 0,
10708 endpoint_connection_attempt_failed: 0,
10709 endpoint_connection_attempt_deduplicated: 0,
10710 platform_tx: 0,
10711 platform_tx_error: 0,
10712 platform_rx: 0,
10713 platform_rx_error: 0,
10714 platform_feature_configured: 0,
10715 platform_event_loop_wakeup: 0,
10716 platform_event_loop_sleep: 0,
10717 platform_event_loop_started: 0,
10718 }
10719 }
10720 }
10721 impl super::EndpointPublisher for Publisher {
10722 fn on_version_information(&mut self, event: builder::VersionInformation) {
10723 self.version_information += 1;
10724 let event = event.into_event();
10725 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10726 let out = format!("{event:?}");
10727 self.output.push(out);
10728 }
10729 fn on_endpoint_packet_sent(&mut self, event: builder::EndpointPacketSent) {
10730 self.endpoint_packet_sent += 1;
10731 let event = event.into_event();
10732 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10733 let out = format!("{event:?}");
10734 self.output.push(out);
10735 }
10736 fn on_endpoint_packet_received(&mut self, event: builder::EndpointPacketReceived) {
10737 self.endpoint_packet_received += 1;
10738 let event = event.into_event();
10739 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10740 let out = format!("{event:?}");
10741 self.output.push(out);
10742 }
10743 fn on_endpoint_datagram_sent(&mut self, event: builder::EndpointDatagramSent) {
10744 self.endpoint_datagram_sent += 1;
10745 let event = event.into_event();
10746 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10747 let out = format!("{event:?}");
10748 self.output.push(out);
10749 }
10750 fn on_endpoint_datagram_received(&mut self, event: builder::EndpointDatagramReceived) {
10751 self.endpoint_datagram_received += 1;
10752 let event = event.into_event();
10753 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10754 let out = format!("{event:?}");
10755 self.output.push(out);
10756 }
10757 fn on_endpoint_datagram_dropped(&mut self, event: builder::EndpointDatagramDropped) {
10758 self.endpoint_datagram_dropped += 1;
10759 let event = event.into_event();
10760 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10761 let out = format!("{event:?}");
10762 self.output.push(out);
10763 }
10764 fn on_endpoint_connection_attempt_failed(
10765 &mut self,
10766 event: builder::EndpointConnectionAttemptFailed,
10767 ) {
10768 self.endpoint_connection_attempt_failed += 1;
10769 let event = event.into_event();
10770 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10771 let out = format!("{event:?}");
10772 self.output.push(out);
10773 }
10774 fn on_endpoint_connection_attempt_deduplicated(
10775 &mut self,
10776 event: builder::EndpointConnectionAttemptDeduplicated,
10777 ) {
10778 self.endpoint_connection_attempt_deduplicated += 1;
10779 let event = event.into_event();
10780 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10781 let out = format!("{event:?}");
10782 self.output.push(out);
10783 }
10784 fn on_platform_tx(&mut self, event: builder::PlatformTx) {
10785 self.platform_tx += 1;
10786 let event = event.into_event();
10787 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10788 let out = format!("{event:?}");
10789 self.output.push(out);
10790 }
10791 fn on_platform_tx_error(&mut self, event: builder::PlatformTxError) {
10792 self.platform_tx_error += 1;
10793 let event = event.into_event();
10794 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10795 let out = format!("{event:?}");
10796 self.output.push(out);
10797 }
10798 fn on_platform_rx(&mut self, event: builder::PlatformRx) {
10799 self.platform_rx += 1;
10800 let event = event.into_event();
10801 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10802 let out = format!("{event:?}");
10803 self.output.push(out);
10804 }
10805 fn on_platform_rx_error(&mut self, event: builder::PlatformRxError) {
10806 self.platform_rx_error += 1;
10807 let event = event.into_event();
10808 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10809 let out = format!("{event:?}");
10810 self.output.push(out);
10811 }
10812 fn on_platform_feature_configured(&mut self, event: builder::PlatformFeatureConfigured) {
10813 self.platform_feature_configured += 1;
10814 let event = event.into_event();
10815 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10816 let out = format!("{event:?}");
10817 self.output.push(out);
10818 }
10819 fn on_platform_event_loop_wakeup(&mut self, event: builder::PlatformEventLoopWakeup) {
10820 self.platform_event_loop_wakeup += 1;
10821 let event = event.into_event();
10822 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10823 let out = format!("{event:?}");
10824 self.output.push(out);
10825 }
10826 fn on_platform_event_loop_sleep(&mut self, event: builder::PlatformEventLoopSleep) {
10827 self.platform_event_loop_sleep += 1;
10828 let event = event.into_event();
10829 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10830 let out = format!("{event:?}");
10831 self.output.push(out);
10832 }
10833 fn on_platform_event_loop_started(&mut self, event: builder::PlatformEventLoopStarted) {
10834 self.platform_event_loop_started += 1;
10835 let event = event.into_event();
10836 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10837 let out = format!("{event:?}");
10838 self.output.push(out);
10839 }
10840 fn quic_version(&self) -> Option<u32> {
10841 Some(1)
10842 }
10843 }
10844 impl super::ConnectionPublisher for Publisher {
10845 fn on_application_protocol_information(
10846 &mut self,
10847 event: builder::ApplicationProtocolInformation,
10848 ) {
10849 self.application_protocol_information += 1;
10850 let event = event.into_event();
10851 if self.location.is_some() {
10852 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10853 let out = format!("{event:?}");
10854 self.output.push(out);
10855 }
10856 }
10857 fn on_server_name_information(&mut self, event: builder::ServerNameInformation) {
10858 self.server_name_information += 1;
10859 let event = event.into_event();
10860 if self.location.is_some() {
10861 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10862 let out = format!("{event:?}");
10863 self.output.push(out);
10864 }
10865 }
10866 fn on_key_exchange_group(&mut self, event: builder::KeyExchangeGroup) {
10867 self.key_exchange_group += 1;
10868 let event = event.into_event();
10869 if self.location.is_some() {
10870 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10871 let out = format!("{event:?}");
10872 self.output.push(out);
10873 }
10874 }
10875 fn on_packet_skipped(&mut self, event: builder::PacketSkipped) {
10876 self.packet_skipped += 1;
10877 let event = event.into_event();
10878 if self.location.is_some() {
10879 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10880 let out = format!("{event:?}");
10881 self.output.push(out);
10882 }
10883 }
10884 fn on_packet_sent(&mut self, event: builder::PacketSent) {
10885 self.packet_sent += 1;
10886 let event = event.into_event();
10887 if self.location.is_some() {
10888 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10889 let out = format!("{event:?}");
10890 self.output.push(out);
10891 }
10892 }
10893 fn on_packet_received(&mut self, event: builder::PacketReceived) {
10894 self.packet_received += 1;
10895 let event = event.into_event();
10896 if self.location.is_some() {
10897 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10898 let out = format!("{event:?}");
10899 self.output.push(out);
10900 }
10901 }
10902 fn on_active_path_updated(&mut self, event: builder::ActivePathUpdated) {
10903 self.active_path_updated += 1;
10904 let event = event.into_event();
10905 if self.location.is_some() {
10906 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10907 let out = format!("{event:?}");
10908 self.output.push(out);
10909 }
10910 }
10911 fn on_path_created(&mut self, event: builder::PathCreated) {
10912 self.path_created += 1;
10913 let event = event.into_event();
10914 if self.location.is_some() {
10915 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10916 let out = format!("{event:?}");
10917 self.output.push(out);
10918 }
10919 }
10920 fn on_frame_sent(&mut self, event: builder::FrameSent) {
10921 self.frame_sent += 1;
10922 let event = event.into_event();
10923 if self.location.is_some() {
10924 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10925 let out = format!("{event:?}");
10926 self.output.push(out);
10927 }
10928 }
10929 fn on_frame_received(&mut self, event: builder::FrameReceived) {
10930 self.frame_received += 1;
10931 let event = event.into_event();
10932 if self.location.is_some() {
10933 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10934 let out = format!("{event:?}");
10935 self.output.push(out);
10936 }
10937 }
10938 fn on_connection_close_frame_received(
10939 &mut self,
10940 event: builder::ConnectionCloseFrameReceived,
10941 ) {
10942 self.connection_close_frame_received += 1;
10943 let event = event.into_event();
10944 if self.location.is_some() {
10945 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10946 let out = format!("{event:?}");
10947 self.output.push(out);
10948 }
10949 }
10950 fn on_packet_lost(&mut self, event: builder::PacketLost) {
10951 self.packet_lost += 1;
10952 let event = event.into_event();
10953 if self.location.is_some() {
10954 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10955 let out = format!("{event:?}");
10956 self.output.push(out);
10957 }
10958 }
10959 fn on_recovery_metrics(&mut self, event: builder::RecoveryMetrics) {
10960 self.recovery_metrics += 1;
10961 let event = event.into_event();
10962 if self.location.is_some() {
10963 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10964 let out = format!("{event:?}");
10965 self.output.push(out);
10966 }
10967 }
10968 fn on_congestion(&mut self, event: builder::Congestion) {
10969 self.congestion += 1;
10970 let event = event.into_event();
10971 if self.location.is_some() {
10972 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10973 let out = format!("{event:?}");
10974 self.output.push(out);
10975 }
10976 }
10977 #[allow(deprecated)]
10978 fn on_ack_processed(&mut self, event: builder::AckProcessed) {
10979 self.ack_processed += 1;
10980 let event = event.into_event();
10981 if self.location.is_some() {
10982 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10983 let out = format!("{event:?}");
10984 self.output.push(out);
10985 }
10986 }
10987 fn on_rx_ack_range_dropped(&mut self, event: builder::RxAckRangeDropped) {
10988 self.rx_ack_range_dropped += 1;
10989 let event = event.into_event();
10990 if self.location.is_some() {
10991 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
10992 let out = format!("{event:?}");
10993 self.output.push(out);
10994 }
10995 }
10996 fn on_ack_range_received(&mut self, event: builder::AckRangeReceived) {
10997 self.ack_range_received += 1;
10998 let event = event.into_event();
10999 if self.location.is_some() {
11000 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11001 let out = format!("{event:?}");
11002 self.output.push(out);
11003 }
11004 }
11005 fn on_ack_range_sent(&mut self, event: builder::AckRangeSent) {
11006 self.ack_range_sent += 1;
11007 let event = event.into_event();
11008 if self.location.is_some() {
11009 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11010 let out = format!("{event:?}");
11011 self.output.push(out);
11012 }
11013 }
11014 fn on_packet_dropped(&mut self, event: builder::PacketDropped) {
11015 self.packet_dropped += 1;
11016 let event = event.into_event();
11017 if self.location.is_some() {
11018 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11019 let out = format!("{event:?}");
11020 self.output.push(out);
11021 }
11022 }
11023 fn on_key_update(&mut self, event: builder::KeyUpdate) {
11024 self.key_update += 1;
11025 let event = event.into_event();
11026 if self.location.is_some() {
11027 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11028 let out = format!("{event:?}");
11029 self.output.push(out);
11030 }
11031 }
11032 fn on_key_space_discarded(&mut self, event: builder::KeySpaceDiscarded) {
11033 self.key_space_discarded += 1;
11034 let event = event.into_event();
11035 if self.location.is_some() {
11036 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11037 let out = format!("{event:?}");
11038 self.output.push(out);
11039 }
11040 }
11041 fn on_connection_started(&mut self, event: builder::ConnectionStarted) {
11042 self.connection_started += 1;
11043 let event = event.into_event();
11044 if self.location.is_some() {
11045 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11046 let out = format!("{event:?}");
11047 self.output.push(out);
11048 }
11049 }
11050 fn on_duplicate_packet(&mut self, event: builder::DuplicatePacket) {
11051 self.duplicate_packet += 1;
11052 let event = event.into_event();
11053 if self.location.is_some() {
11054 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11055 let out = format!("{event:?}");
11056 self.output.push(out);
11057 }
11058 }
11059 fn on_transport_parameters_received(
11060 &mut self,
11061 event: builder::TransportParametersReceived,
11062 ) {
11063 self.transport_parameters_received += 1;
11064 let event = event.into_event();
11065 if self.location.is_some() {
11066 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11067 let out = format!("{event:?}");
11068 self.output.push(out);
11069 }
11070 }
11071 fn on_datagram_sent(&mut self, event: builder::DatagramSent) {
11072 self.datagram_sent += 1;
11073 let event = event.into_event();
11074 if self.location.is_some() {
11075 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11076 let out = format!("{event:?}");
11077 self.output.push(out);
11078 }
11079 }
11080 fn on_datagram_received(&mut self, event: builder::DatagramReceived) {
11081 self.datagram_received += 1;
11082 let event = event.into_event();
11083 if self.location.is_some() {
11084 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11085 let out = format!("{event:?}");
11086 self.output.push(out);
11087 }
11088 }
11089 fn on_datagram_dropped(&mut self, event: builder::DatagramDropped) {
11090 self.datagram_dropped += 1;
11091 let event = event.into_event();
11092 if self.location.is_some() {
11093 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11094 let out = format!("{event:?}");
11095 self.output.push(out);
11096 }
11097 }
11098 fn on_handshake_remote_address_change_observed(
11099 &mut self,
11100 event: builder::HandshakeRemoteAddressChangeObserved,
11101 ) {
11102 self.handshake_remote_address_change_observed += 1;
11103 let event = event.into_event();
11104 if self.location.is_some() {
11105 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11106 let out = format!("{event:?}");
11107 self.output.push(out);
11108 }
11109 }
11110 fn on_connection_id_updated(&mut self, event: builder::ConnectionIdUpdated) {
11111 self.connection_id_updated += 1;
11112 let event = event.into_event();
11113 if self.location.is_some() {
11114 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11115 let out = format!("{event:?}");
11116 self.output.push(out);
11117 }
11118 }
11119 fn on_ecn_state_changed(&mut self, event: builder::EcnStateChanged) {
11120 self.ecn_state_changed += 1;
11121 let event = event.into_event();
11122 if self.location.is_some() {
11123 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11124 let out = format!("{event:?}");
11125 self.output.push(out);
11126 }
11127 }
11128 fn on_connection_migration_denied(&mut self, event: builder::ConnectionMigrationDenied) {
11129 self.connection_migration_denied += 1;
11130 let event = event.into_event();
11131 if self.location.is_some() {
11132 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11133 let out = format!("{event:?}");
11134 self.output.push(out);
11135 }
11136 }
11137 fn on_handshake_status_updated(&mut self, event: builder::HandshakeStatusUpdated) {
11138 self.handshake_status_updated += 1;
11139 let event = event.into_event();
11140 if self.location.is_some() {
11141 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11142 let out = format!("{event:?}");
11143 self.output.push(out);
11144 }
11145 }
11146 fn on_tls_exporter_ready(&mut self, event: builder::TlsExporterReady) {
11147 self.tls_exporter_ready += 1;
11148 let event = event.into_event();
11149 if self.location.is_some() {
11150 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11151 let out = format!("{event:?}");
11152 self.output.push(out);
11153 }
11154 }
11155 fn on_tls_handshake_failed(&mut self, event: builder::TlsHandshakeFailed) {
11156 self.tls_handshake_failed += 1;
11157 let event = event.into_event();
11158 if self.location.is_some() {
11159 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11160 let out = format!("{event:?}");
11161 self.output.push(out);
11162 }
11163 }
11164 fn on_path_challenge_updated(&mut self, event: builder::PathChallengeUpdated) {
11165 self.path_challenge_updated += 1;
11166 let event = event.into_event();
11167 if self.location.is_some() {
11168 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11169 let out = format!("{event:?}");
11170 self.output.push(out);
11171 }
11172 }
11173 fn on_tls_client_hello(&mut self, event: builder::TlsClientHello) {
11174 self.tls_client_hello += 1;
11175 let event = event.into_event();
11176 if self.location.is_some() {
11177 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11178 let out = format!("{event:?}");
11179 self.output.push(out);
11180 }
11181 }
11182 fn on_tls_server_hello(&mut self, event: builder::TlsServerHello) {
11183 self.tls_server_hello += 1;
11184 let event = event.into_event();
11185 if self.location.is_some() {
11186 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11187 let out = format!("{event:?}");
11188 self.output.push(out);
11189 }
11190 }
11191 fn on_rx_stream_progress(&mut self, event: builder::RxStreamProgress) {
11192 self.rx_stream_progress += 1;
11193 let event = event.into_event();
11194 if self.location.is_some() {
11195 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11196 let out = format!("{event:?}");
11197 self.output.push(out);
11198 }
11199 }
11200 fn on_tx_stream_progress(&mut self, event: builder::TxStreamProgress) {
11201 self.tx_stream_progress += 1;
11202 let event = event.into_event();
11203 if self.location.is_some() {
11204 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11205 let out = format!("{event:?}");
11206 self.output.push(out);
11207 }
11208 }
11209 fn on_keep_alive_timer_expired(&mut self, event: builder::KeepAliveTimerExpired) {
11210 self.keep_alive_timer_expired += 1;
11211 let event = event.into_event();
11212 if self.location.is_some() {
11213 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11214 let out = format!("{event:?}");
11215 self.output.push(out);
11216 }
11217 }
11218 fn on_mtu_updated(&mut self, event: builder::MtuUpdated) {
11219 self.mtu_updated += 1;
11220 let event = event.into_event();
11221 if self.location.is_some() {
11222 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11223 let out = format!("{event:?}");
11224 self.output.push(out);
11225 }
11226 }
11227 fn on_slow_start_exited(&mut self, event: builder::SlowStartExited) {
11228 self.slow_start_exited += 1;
11229 let event = event.into_event();
11230 if self.location.is_some() {
11231 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11232 let out = format!("{event:?}");
11233 self.output.push(out);
11234 }
11235 }
11236 fn on_delivery_rate_sampled(&mut self, event: builder::DeliveryRateSampled) {
11237 self.delivery_rate_sampled += 1;
11238 let event = event.into_event();
11239 if self.location.is_some() {
11240 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11241 let out = format!("{event:?}");
11242 self.output.push(out);
11243 }
11244 }
11245 fn on_pacing_rate_updated(&mut self, event: builder::PacingRateUpdated) {
11246 self.pacing_rate_updated += 1;
11247 let event = event.into_event();
11248 if self.location.is_some() {
11249 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11250 let out = format!("{event:?}");
11251 self.output.push(out);
11252 }
11253 }
11254 fn on_bbr_state_changed(&mut self, event: builder::BbrStateChanged) {
11255 self.bbr_state_changed += 1;
11256 let event = event.into_event();
11257 if self.location.is_some() {
11258 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11259 let out = format!("{event:?}");
11260 self.output.push(out);
11261 }
11262 }
11263 fn on_dc_state_changed(&mut self, event: builder::DcStateChanged) {
11264 self.dc_state_changed += 1;
11265 let event = event.into_event();
11266 if self.location.is_some() {
11267 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11268 let out = format!("{event:?}");
11269 self.output.push(out);
11270 }
11271 }
11272 fn on_dc_path_created(&mut self, event: builder::DcPathCreated) {
11273 self.dc_path_created += 1;
11274 let event = event.into_event();
11275 if self.location.is_some() {
11276 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11277 let out = format!("{event:?}");
11278 self.output.push(out);
11279 }
11280 }
11281 fn on_connection_closed(&mut self, event: builder::ConnectionClosed) {
11282 self.connection_closed += 1;
11283 let event = event.into_event();
11284 if self.location.is_some() {
11285 let event = crate::event::snapshot::Fmt::to_snapshot(&event);
11286 let out = format!("{event:?}");
11287 self.output.push(out);
11288 }
11289 }
11290 fn quic_version(&self) -> u32 {
11291 1
11292 }
11293 fn subject(&self) -> api::Subject {
11294 builder::Subject::Connection { id: 0 }.into_event()
11295 }
11296 }
11297 impl Drop for Publisher {
11298 fn drop(&mut self) {
11299 if std::thread::panicking() {
11300 return;
11301 }
11302 if let Some(location) = self.location.as_ref() {
11303 location.snapshot_log(&self.output);
11304 }
11305 }
11306 }
11307}