#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct Limits {
pub max_xml_bytes: u64,
pub max_stylesheet_bytes: u64,
pub xpath_operations: u64,
pub pcre_backtrack_limit: u32,
pub pcre_recursion_limit: u32,
}
impl Default for Limits {
fn default() -> Self {
Self {
max_xml_bytes: 16 * 1024 * 1024,
max_stylesheet_bytes: 8 * 1024 * 1024,
xpath_operations: 200_000_000,
pcre_backtrack_limit: 1_000_000,
pcre_recursion_limit: 100_000,
}
}
}
impl Limits {
#[must_use]
pub fn new() -> Self {
Self::default()
}
#[must_use]
pub const fn with_max_xml_bytes(mut self, bytes: u64) -> Self {
self.max_xml_bytes = bytes;
self
}
#[must_use]
pub const fn with_max_stylesheet_bytes(mut self, bytes: u64) -> Self {
self.max_stylesheet_bytes = bytes;
self
}
#[must_use]
pub const fn with_xpath_operations(mut self, operations: u64) -> Self {
self.xpath_operations = operations;
self
}
}