pub struct ParseOptions {
pub limits: Limits,
pub reference_mode: ReferenceMode,
}Expand description
Parsing options for configuring HEDL document parsing behavior.
ParseOptions provides both direct field access and a fluent builder API for convenient configuration. All parsing functions accept ParseOptions to customize limits, security settings, and error handling behavior.
§Creating ParseOptions
§Using the builder pattern (recommended)
use hedl_core::ParseOptions;
// Typical strict parsing with custom depth limit
let opts = ParseOptions::builder()
.max_depth(100)
.strict(true)
.build();
// Lenient parsing for large datasets
let opts = ParseOptions::builder()
.max_array_length(50_000)
.strict(false)
.max_block_string_size(50 * 1024 * 1024)
.build();
// Restrictive parsing for security
let opts = ParseOptions::builder()
.max_file_size(10 * 1024 * 1024)
.max_line_length(64 * 1024)
.max_depth(20)
.max_array_length(1000)
.strict(true)
.build();§Using defaults
use hedl_core::{ParseOptions, parse_with_limits};
// Default options: strict refs, normal limits
let opts = ParseOptions::default();
// Parse with defaults
let doc = parse_with_limits(input, opts)?;§Direct field access
use hedl_core::{ParseOptions, Limits};
let mut opts = ParseOptions::default();
opts.reference_mode = false;
opts.limits.max_nodes = 5000;§Security Considerations
ParseOptions includes multiple security limits to prevent denial-of-service attacks:
max_file_size: Prevents loading extremely large filesmax_line_length: Prevents regex DOS via extremely long linesmax_indent_depth: Prevents stack overflow via deep nestingmax_nodes: Prevents memory exhaustion via large matrix listsmax_object_keysandmax_total_keys: Prevent memory exhaustion via many objectsmax_nest_depth: Prevents stack overflow via deeply nested NEST hierarchiesmax_block_string_size: Prevents memory exhaustion via large block strings
§Fields
limits: Security limits for parser resourcesreference_mode: Reference resolution mode (strict or lenient)
Fields§
§limits: LimitsSecurity limits.
reference_mode: ReferenceModeReference resolution mode (strict or lenient).
Controls how unresolved references are handled:
ReferenceMode::Strict: Errors on unresolved references (default)ReferenceMode::Lenient: Ignores unresolved references
Note: Ambiguous references always error regardless of mode.
Implementations§
Source§impl ParseOptions
impl ParseOptions
Sourcepub fn builder() -> ParseOptionsBuilder
pub fn builder() -> ParseOptionsBuilder
Create a new builder for ParseOptions.
§Examples
let opts = ParseOptions::builder()
.max_depth(100)
.strict(true)
.build();Trait Implementations§
Source§impl Clone for ParseOptions
impl Clone for ParseOptions
Source§fn clone(&self) -> ParseOptions
fn clone(&self) -> ParseOptions
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ParseOptions
impl Debug for ParseOptions
Auto Trait Implementations§
impl Freeze for ParseOptions
impl RefUnwindSafe for ParseOptions
impl Send for ParseOptions
impl Sync for ParseOptions
impl Unpin for ParseOptions
impl UnwindSafe for ParseOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more