Skip to main content

sark_http/h1/chunk/
limit.rs

1#[derive(Clone, Copy)]
2pub struct Limit {
3    pub(super) body_bytes: usize,
4    pub(super) wire_bytes: usize,
5    pub(super) line_bytes: usize,
6    pub(super) trailer_bytes: usize,
7    pub(super) trailer_fields: usize,
8}
9
10impl Limit {
11    pub(in crate::h1) const fn trailers(self) -> usize {
12        self.trailer_bytes
13    }
14
15    pub const fn with_body(body: usize) -> Self {
16        Self::new(body, usize::MAX, 1024, 16 * 1024, 128)
17    }
18
19    pub const fn new(
20        body: usize,
21        wire: usize,
22        line: usize,
23        trailers: usize,
24        fields: usize,
25    ) -> Self {
26        Self {
27            body_bytes: body,
28            wire_bytes: wire,
29            line_bytes: line,
30            trailer_bytes: trailers,
31            trailer_fields: fields,
32        }
33    }
34}