#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Limits {
pub max_total_bytes: usize,
pub max_chunks: usize,
pub max_json_bytes: usize,
pub max_poster_bytes: usize,
pub max_canvas_pixels: usize,
}
impl Limits {
#[must_use]
pub const fn new() -> Self {
Self {
max_total_bytes: 10 * 1024 * 1024,
max_chunks: 16,
max_json_bytes: 1024 * 1024,
max_poster_bytes: 4 * 1024 * 1024,
max_canvas_pixels: 2_000_000,
}
}
#[must_use]
pub const fn with_max_total_bytes(mut self, bytes: usize) -> Self {
self.max_total_bytes = bytes;
self
}
#[must_use]
pub const fn with_max_json_bytes(mut self, bytes: usize) -> Self {
self.max_json_bytes = bytes;
self
}
#[must_use]
pub const fn with_max_canvas_pixels(mut self, pixels: usize) -> Self {
self.max_canvas_pixels = pixels;
self
}
}
impl Default for Limits {
fn default() -> Self {
Self::new()
}
}