///|
/// Resource limits applied before and during parsing.
pub struct Limits {
max_input_bytes : Int
max_lines : Int
max_line_bytes : Int
max_media : Int
max_attributes : Int
max_formats_per_media : Int
max_timings : Int
max_repeats_per_timing : Int
}
///|
pub fn limits(
max_input_bytes : Int,
max_lines : Int,
max_line_bytes : Int,
max_media : Int,
max_attributes : Int,
max_formats_per_media : Int,
max_timings : Int,
max_repeats_per_timing : Int,
) -> Limits {
{
max_input_bytes,
max_lines,
max_line_bytes,
max_media,
max_attributes,
max_formats_per_media,
max_timings,
max_repeats_per_timing,
}
}
///|
pub fn strict_limits() -> Limits {
limits(65536, 1000, 2048, 32, 512, 64, 32, 64)
}
///|
pub fn default_limits() -> Limits {
limits(1048576, 10000, 16384, 256, 4096, 256, 256, 512)
}
///|
pub fn permissive_limits() -> Limits {
limits(8388608, 100000, 65536, 2048, 65536, 1024, 4096, 4096)
}
///|
pub fn Limits::max_input_bytes(self : Limits) -> Int {
self.max_input_bytes
}
///|
pub fn Limits::max_lines(self : Limits) -> Int {
self.max_lines
}
///|
pub fn Limits::max_line_bytes(self : Limits) -> Int {
self.max_line_bytes
}
///|
pub fn Limits::max_media(self : Limits) -> Int {
self.max_media
}
///|
pub fn Limits::max_attributes(self : Limits) -> Int {
self.max_attributes
}
///|
pub fn Limits::max_formats_per_media(self : Limits) -> Int {
self.max_formats_per_media
}
///|
pub fn Limits::max_timings(self : Limits) -> Int {
self.max_timings
}
///|
pub fn Limits::max_repeats_per_timing(self : Limits) -> Int {
self.max_repeats_per_timing
}
///|
/// Parser policy. Strict mode rejects non-CRLF input and obsolete `k=` lines.
pub struct ParseOptions {
strict : Bool
allow_lf : Bool
allow_obsolete_key : Bool
limits : Limits
}
///|
pub fn parse_options(
strict : Bool,
allow_lf : Bool,
allow_obsolete_key : Bool,
limits : Limits,
) -> ParseOptions {
{ strict, allow_lf, allow_obsolete_key, limits }
}
///|
pub fn strict_options() -> ParseOptions {
parse_options(true, false, false, strict_limits())
}
///|
pub fn compatible_options() -> ParseOptions {
parse_options(false, true, true, default_limits())
}
///|
pub fn ParseOptions::strict(self : ParseOptions) -> Bool {
self.strict
}
///|
pub fn ParseOptions::allow_lf(self : ParseOptions) -> Bool {
self.allow_lf
}
///|
pub fn ParseOptions::allow_obsolete_key(self : ParseOptions) -> Bool {
self.allow_obsolete_key
}
///|
pub fn ParseOptions::limits(self : ParseOptions) -> Limits {
self.limits
}