#[derive(Debug, Clone)]
pub struct Limits {
pub max_nesting_depth: usize,
pub max_block_size: usize,
pub max_items: usize,
pub max_memory: usize,
pub max_string_length: usize,
}
impl Default for Limits {
fn default() -> Self {
Self {
max_nesting_depth: 128,
max_block_size: 64 * 1024 * 1024, max_items: 1_000_000, max_memory: 256 * 1024 * 1024, max_string_length: 16 * 1024 * 1024, }
}
}
impl Limits {
pub fn strict() -> Self {
Self {
max_nesting_depth: 32,
max_block_size: 1024 * 1024, max_items: 10_000,
max_memory: 4 * 1024 * 1024, max_string_length: 65536, }
}
pub fn unlimited() -> Self {
Self {
max_nesting_depth: usize::MAX,
max_block_size: usize::MAX,
max_items: usize::MAX,
max_memory: usize::MAX,
max_string_length: usize::MAX,
}
}
}