Skip to main content

sark_http/h1/head/
limit.rs

1use crate::h1::field;
2
3#[derive(Clone, Copy, PartialEq, Eq)]
4pub struct Limit {
5    bytes: usize,
6    fields: field::Limit,
7}
8
9impl Limit {
10    pub const DEFAULT: Self = Self::new(128, 8 * 1024);
11    pub const RESPONSE: Self = Self::new(100, usize::MAX);
12
13    pub const fn new(fields: usize, line: usize) -> Self {
14        Self {
15            bytes: usize::MAX,
16            fields: field::Limit::new(fields, line),
17        }
18    }
19
20    pub const fn with_bytes(self, bytes: usize) -> Self {
21        Self { bytes, ..self }
22    }
23
24    pub(super) const fn bytes(self) -> usize {
25        self.bytes
26    }
27
28    pub(super) const fn fields(self) -> field::Limit {
29        self.fields
30    }
31}