Skip to content

Commit 78edc30

Browse files
committed
feat(quinn): add serde support
Signed-off-by: loongtao.zhang <[email protected]>
1 parent eee334d commit 78edc30

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

quinn-proto/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ tracing-log = ["tracing/log"]
3535
rustls-log = ["rustls?/logging"]
3636
# Enable qlog support
3737
qlog = ["dep:qlog"]
38+
# Add serde support.
39+
serde = ["dep:serde"]
3840

3941
# Internal (PRIVATE!) features used to aid testing.
4042
# Don't rely on these whatsoever. They may disappear at any time.
@@ -57,6 +59,7 @@ slab = { workspace = true }
5759
thiserror = { workspace = true }
5860
tinyvec = { workspace = true, features = ["alloc"] }
5961
tracing = { workspace = true }
62+
serde = { workspace = true, optional = true }
6063

6164
# Feature flags & dependencies for wasm
6265
# wasm-bindgen is assumed for a wasm*-*-unknown target

quinn-proto/src/connection/stats.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use crate::{Dir, Duration, frame::Frame};
66
///
77
/// All QUIC packets are carried by UDP datagrams. Hence, these statistics cover all traffic on a connection.
88
#[derive(Default, Debug, Copy, Clone)]
9+
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
910
#[non_exhaustive]
1011
pub struct UdpStats {
1112
/// The amount of UDP datagrams observed
@@ -28,6 +29,7 @@ impl UdpStats {
2829

2930
/// Number of frames transmitted or received of each frame type
3031
#[derive(Default, Copy, Clone)]
32+
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
3133
#[non_exhaustive]
3234
#[allow(missing_docs)]
3335
pub struct FrameStats {
@@ -132,6 +134,7 @@ impl std::fmt::Debug for FrameStats {
132134

133135
/// Statistics related to a transmission path
134136
#[derive(Debug, Default, Copy, Clone)]
137+
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
135138
#[non_exhaustive]
136139
pub struct PathStats {
137140
/// Current best estimate of this connection's latency (round-trip-time)
@@ -159,6 +162,7 @@ pub struct PathStats {
159162

160163
/// Connection statistics
161164
#[derive(Debug, Default, Copy, Clone)]
165+
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
162166
#[non_exhaustive]
163167
pub struct ConnectionStats {
164168
/// Statistics about UDP datagrams transmitted on a connection

quinn/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ tracing-log = ["tracing/log", "proto/tracing-log", "udp/tracing-log"]
4444
rustls-log = ["rustls?/logging"]
4545
# Enable qlog support
4646
qlog = ["proto/qlog"]
47+
# Add serde support.
48+
serde = ["dep:serde"]
4749

4850
# Internal (PRIVATE!) features used to aid testing.
4951
# Don't rely on these whatsoever. They may disappear at any time.
@@ -64,6 +66,7 @@ thiserror = { workspace = true }
6466
tracing = { workspace = true }
6567
tokio = { workspace = true }
6668
udp = { package = "quinn-udp", path = "../quinn-udp", version = "0.6", default-features = false, features = ["tracing"] }
69+
serde = { workspace = true, optional = true }
6770

6871
[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dependencies]
6972
socket2 = { workspace = true }

quinn/src/endpoint.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ impl Endpoint {
334334
/// Statistics on [Endpoint] activity
335335
#[non_exhaustive]
336336
#[derive(Debug, Default, Copy, Clone)]
337+
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
337338
pub struct EndpointStats {
338339
/// Cummulative number of Quic handshakes accepted by this [Endpoint]
339340
pub accepted_handshakes: u64,

0 commit comments

Comments
 (0)