#[non_exhaustive]pub enum BodyMode {
Stream,
StreamBuffer {
max_bytes: Option<usize>,
},
SizeLimit {
max_bytes: usize,
},
}Expand description
Controls how body chunks are delivered to a filter.
use praxis_filter::BodyMode;
let mode = BodyMode::default();
assert!(matches!(mode, BodyMode::Stream));
let buffered = BodyMode::StreamBuffer {
max_bytes: Some(1024),
};
assert!(matches!(
buffered,
BodyMode::StreamBuffer {
max_bytes: Some(1024)
}
));
let stream_buf = BodyMode::StreamBuffer { max_bytes: None };
assert!(matches!(
stream_buf,
BodyMode::StreamBuffer { max_bytes: None }
));
let limited = BodyMode::StreamBuffer {
max_bytes: Some(1024),
};
assert!(matches!(
limited,
BodyMode::StreamBuffer {
max_bytes: Some(1024)
}
));
let size_limited = BodyMode::SizeLimit { max_bytes: 2048 };
assert!(matches!(
size_limited,
BodyMode::SizeLimit { max_bytes: 2048 }
));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Stream
Deliver chunks as they arrive. Low latency, low memory.
use praxis_filter::BodyMode;
let mode = BodyMode::Stream;
assert_eq!(mode, BodyMode::default());StreamBuffer
Deliver chunks incrementally (like Stream) but accumulate
them and defer upstream forwarding until a filter returns
FilterAction::Release or end-of-stream is reached.
When max_bytes is Some, requests exceeding the limit
receive 413. When None and no global body size ceiling is
configured, body buffering is unbounded; a warning is emitted
at pipeline build time in that case.
use praxis_filter::BodyMode;
let unlimited = BodyMode::StreamBuffer { max_bytes: None };
assert!(matches!(
unlimited,
BodyMode::StreamBuffer { max_bytes: None }
));
let limited = BodyMode::StreamBuffer {
max_bytes: Some(4096),
};
assert!(matches!(
limited,
BodyMode::StreamBuffer {
max_bytes: Some(4096)
}
));Fields
SizeLimit
Stream chunks through without buffering, but enforce a byte
ceiling. Returns 413 if the running byte count exceeds
max_bytes.
Used by apply_body_limits when no filter needs body access
but a global size limit is configured.
use praxis_filter::BodyMode;
let mode = BodyMode::SizeLimit { max_bytes: 4096 };
assert!(matches!(mode, BodyMode::SizeLimit { max_bytes: 4096 }));Trait Implementations§
impl Copy for BodyMode
impl Eq for BodyMode
impl StructuralPartialEq for BodyMode
Auto Trait Implementations§
impl Freeze for BodyMode
impl RefUnwindSafe for BodyMode
impl Send for BodyMode
impl Sync for BodyMode
impl Unpin for BodyMode
impl UnsafeUnpin for BodyMode
impl UnwindSafe for BodyMode
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.