1mod buffer;
2mod counts;
3mod flow_control;
4mod prioritize;
5mod recv;
6mod send;
7mod state;
8mod store;
9mod stream;
10#[allow(clippy::module_inception)]
11mod streams;
12
13pub(crate) use self::prioritize::Prioritized;
14pub(crate) use self::recv::Open;
15pub(crate) use self::send::PollReset;
16pub(crate) use self::streams::{DynStreams, OpaqueStreamRef, StreamRef, Streams};
17
18use self::buffer::Buffer;
19use self::counts::Counts;
20use self::flow_control::FlowControl;
21use self::prioritize::Prioritize;
22use self::recv::Recv;
23use self::send::Send;
24use self::state::State;
25use self::store::Store;
26use self::stream::Stream;
27
28use crate::frame::{StreamId, StreamIdOverflow};
29use crate::proto::*;
30
31use bytes::Bytes;
32use std::time::Duration;
33
34#[derive(Debug)]
35pub struct Config {
36 pub initial_max_send_streams: usize,
41
42 pub local_max_buffer_size: usize,
44
45 pub local_next_stream_id: StreamId,
47
48 pub local_push_enabled: bool,
50
51 pub extended_connect_protocol_enabled: bool,
53
54 pub local_reset_duration: Duration,
56
57 pub local_reset_max: usize,
59
60 pub remote_reset_max: usize,
63
64 pub remote_init_window_sz: WindowSize,
66
67 pub remote_max_initiated: Option<usize>,
69
70 pub local_max_error_reset_streams: Option<usize>,
75}
76
77trait DebugStructExt<'a, 'b> {
78 fn h2_field_if(&mut self, name: &str, val: &bool) -> &mut std::fmt::DebugStruct<'a, 'b>;
80
81 fn h2_field_if_then<T: std::fmt::Debug>(
82 &mut self,
83 name: &str,
84 cond: bool,
85 val: &T,
86 ) -> &mut std::fmt::DebugStruct<'a, 'b>;
87
88 fn h2_field_some<T: std::fmt::Debug>(
89 &mut self,
90 name: &str,
91 val: &Option<T>,
92 ) -> &mut std::fmt::DebugStruct<'a, 'b>;
93}
94
95impl<'a, 'b> DebugStructExt<'a, 'b> for std::fmt::DebugStruct<'a, 'b> {
96 fn h2_field_if(&mut self, name: &str, val: &bool) -> &mut std::fmt::DebugStruct<'a, 'b> {
97 if *val {
98 self.field(name, val)
99 } else {
100 self
101 }
102 }
103
104 fn h2_field_if_then<T: std::fmt::Debug>(
105 &mut self,
106 name: &str,
107 cond: bool,
108 val: &T,
109 ) -> &mut std::fmt::DebugStruct<'a, 'b> {
110 if cond {
111 self.field(name, val)
112 } else {
113 self
114 }
115 }
116
117 fn h2_field_some<T: std::fmt::Debug>(
118 &mut self,
119 name: &str,
120 val: &Option<T>,
121 ) -> &mut std::fmt::DebugStruct<'a, 'b> {
122 if val.is_some() {
123 self.field(name, val)
124 } else {
125 self
126 }
127 }
128}