Skip to main content

Module utils

Module utils 

Source

Structs§

CappedIter
Iterator adapter that yields at most MAX_ITERATION_COUNT items and emits a crate::parser_warn! diagnostic, naming context, if the underlying iterator actually had more items than the cap.
RecursionGuard
A reusable guard that tracks recursion depth and detects cycles.

Constants§

MAX_FIELD_LENGTH
Default maximum length for individual string field values (10 MB).
MAX_ITERATION_COUNT
Default maximum iteration count for loops processing items (100,000).
MAX_MANIFEST_SIZE
Default maximum file size for non-archive manifest files (100 MB).
MAX_RECURSION_DEPTH
Default maximum recursion depth for recursive parsing functions (50 levels).

Traits§

CappedIterExt
Extension trait providing capped on any iterator.

Functions§

capped_iteration_limit
Returns the number of items to iterate for a collection of total_len, capped at MAX_ITERATION_COUNT, and emits a crate::parser_warn! diagnostic when the cap actually truncates the input.
npm_purl
Creates a correctly-formatted npm Package URL for scoped or regular packages.
parse_sri
Parses Subresource Integrity (SRI) format and returns hash as hex string.
read_file_to_string
Reads a file’s entire contents into a String with ADR 0004 security checks.
split_name_email
Parses “Name email@domain.com” format into separate components.
truncate_field
Truncates a string field value to MAX_FIELD_LENGTH bytes if it exceeds the limit, returning the truncated string. Returns the original string if within limits.