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, Eq, PartialEq)]
35pub(super) enum BufferStatus {
36 Complete,
37 CodecFull,
38}
39
40#[derive(Debug)]
41pub struct Config {
42 pub initial_max_send_streams: usize,
47
48 pub local_max_buffer_size: usize,
50
51 pub local_next_stream_id: StreamId,
53
54 pub local_push_enabled: bool,
56
57 pub extended_connect_protocol_enabled: bool,
59
60 pub local_reset_duration: Duration,
62
63 pub local_reset_max: usize,
65
66 pub remote_reset_max: usize,
69
70 pub remote_init_window_sz: WindowSize,
72
73 pub remote_max_initiated: Option<usize>,
75
76 pub local_max_error_reset_streams: Option<usize>,
81
82 pub data_frame_budget: usize,
86}
87
88trait DebugStructExt<'a, 'b> {
89 fn h2_field_if(&mut self, name: &str, val: &bool) -> &mut std::fmt::DebugStruct<'a, 'b>;
91
92 fn h2_field_if_then<T: std::fmt::Debug>(
93 &mut self,
94 name: &str,
95 cond: bool,
96 val: &T,
97 ) -> &mut std::fmt::DebugStruct<'a, 'b>;
98
99 fn h2_field_some<T: std::fmt::Debug>(
100 &mut self,
101 name: &str,
102 val: &Option<T>,
103 ) -> &mut std::fmt::DebugStruct<'a, 'b>;
104}
105
106impl<'a, 'b> DebugStructExt<'a, 'b> for std::fmt::DebugStruct<'a, 'b> {
107 fn h2_field_if(&mut self, name: &str, val: &bool) -> &mut std::fmt::DebugStruct<'a, 'b> {
108 if *val {
109 self.field(name, val)
110 } else {
111 self
112 }
113 }
114
115 fn h2_field_if_then<T: std::fmt::Debug>(
116 &mut self,
117 name: &str,
118 cond: bool,
119 val: &T,
120 ) -> &mut std::fmt::DebugStruct<'a, 'b> {
121 if cond {
122 self.field(name, val)
123 } else {
124 self
125 }
126 }
127
128 fn h2_field_some<T: std::fmt::Debug>(
129 &mut self,
130 name: &str,
131 val: &Option<T>,
132 ) -> &mut std::fmt::DebugStruct<'a, 'b> {
133 if val.is_some() {
134 self.field(name, val)
135 } else {
136 self
137 }
138 }
139}