1515/// let mode = BodyMode::default();
1616/// assert!(matches!(mode, BodyMode::Stream));
1717///
18- /// let buffered = BodyMode::Buffer { max_bytes: 1024 };
19- /// assert!(matches!(buffered, BodyMode::Buffer { max_bytes: 1024 }));
18+ /// let buffered = BodyMode::StreamBuffer {
19+ /// max_bytes: Some(1024),
20+ /// };
21+ /// assert!(matches!(
22+ /// buffered,
23+ /// BodyMode::StreamBuffer {
24+ /// max_bytes: Some(1024)
25+ /// }
26+ /// ));
2027///
2128/// let stream_buf = BodyMode::StreamBuffer { max_bytes: None };
2229/// assert!(matches!(
4148/// ));
4249/// ```
4350#[ derive( Debug , Clone , Copy , PartialEq , Eq , Default ) ]
51+ #[ non_exhaustive]
4452pub enum BodyMode {
4553 /// Deliver chunks as they arrive. Low latency, low memory.
4654 ///
@@ -53,19 +61,6 @@ pub enum BodyMode {
5361 #[ default]
5462 Stream ,
5563
56- /// Buffer the entire body, then deliver it in a single call.
57- ///
58- /// ```
59- /// use praxis_filter::BodyMode;
60- ///
61- /// let mode = BodyMode::Buffer { max_bytes: 8192 };
62- /// assert!(matches!(mode, BodyMode::Buffer { max_bytes: 8192 }));
63- /// ```
64- Buffer {
65- /// Maximum body size in bytes.
66- max_bytes : usize ,
67- } ,
68-
6964 /// Deliver chunks incrementally (like [`Stream`]) but accumulate
7065 /// them and defer upstream forwarding until a filter returns
7166 /// [`FilterAction::Release`] or end-of-stream is reached.
@@ -141,16 +136,6 @@ mod tests {
141136 ) ;
142137 }
143138
144- #[ test]
145- fn body_mode_buffer_carries_limit ( ) {
146- let mode = BodyMode :: Buffer { max_bytes : 4096 } ;
147-
148- assert ! (
149- matches!( mode, BodyMode :: Buffer { max_bytes: 4096 } ) ,
150- "Buffer variant should carry configured limit"
151- ) ;
152- }
153-
154139 #[ test]
155140 fn body_mode_stream_buffer_unlimited ( ) {
156141 let mode = BodyMode :: StreamBuffer { max_bytes : None } ;
@@ -179,21 +164,16 @@ mod tests {
179164 }
180165
181166 #[ test]
182- fn body_mode_size_limit_is_distinct_from_buffer ( ) {
167+ fn body_mode_size_limit_is_distinct_from_stream_buffer ( ) {
183168 assert_ne ! (
184169 BodyMode :: SizeLimit { max_bytes: 100 } ,
185- BodyMode :: Buffer { max_bytes: 100 } ,
186- "SizeLimit and Buffer should be distinct even with same limit"
170+ BodyMode :: StreamBuffer { max_bytes: Some ( 100 ) } ,
171+ "SizeLimit and StreamBuffer should be distinct even with same limit"
187172 ) ;
188173 }
189174
190175 #[ test]
191- fn body_mode_stream_buffer_is_distinct ( ) {
192- assert_ne ! (
193- BodyMode :: StreamBuffer { max_bytes: None } ,
194- BodyMode :: Buffer { max_bytes: 100 } ,
195- "StreamBuffer and Buffer should be distinct variants"
196- ) ;
176+ fn body_mode_stream_buffer_is_distinct_from_stream ( ) {
197177 assert_ne ! (
198178 BodyMode :: StreamBuffer { max_bytes: None } ,
199179 BodyMode :: Stream ,
0 commit comments