pub struct ValidateOptions<'a> { /* private fields */ }Expand description
Options of one validation.
Implementations§
Source§impl<'a> ValidateOptions<'a>
impl<'a> ValidateOptions<'a>
Sourcepub const fn new() -> Self
pub const fn new() -> Self
The default options: the document has no URI, the clock is the system clock in
UTC, the maximum element depth is DEFAULT_MAX_DEPTH and the stack the
stylesheets may use is DEFAULT_MAX_STACK.
Sourcepub const fn fail_closed(self, fail_closed: bool) -> Self
pub const fn fail_closed(self, fail_closed: bool) -> Self
Fail closed: a finding that would otherwise be of severity
Severity::Other (a flag other than fatal and
warning, or none, unless the manifest of the rule set gives it a severity) is of
severity Severity::Fatal: it makes the document
invalid. Off by default. For rule sets whose flags the caller does not know in
advance: every finding that is not a warning then rejects the document.
Sourcepub const fn max_depth(self, max_depth: u32) -> Self
pub const fn max_depth(self, max_depth: u32) -> Self
The maximum element depth of the document, and of any document a stylesheet
loads with document(): the document element is at depth 1, its children at
depth 2, and so on. A document with an element nested deeper is refused with
Error::Limit before its schema is checked. Default: DEFAULT_MAX_DEPTH
(256, libxml2’s default).
The stylesheets apply their template rules one element level inside another, so
their stack use grows with the depth: with the default, a validation runs on a
thread with the default 2 MiB stack, debug builds included. The nesting of
template and function invocations the stylesheets are allowed grows with the
maximum (max_nesting_for_depth), and so does the
stack they need: a larger maximum depth needs a larger
ValidateOptions::max_stack, and a thread with that much stack.
On WebAssembly, at most WASM_MAX_DEPTH: a validation asking for more fails with
Error::OptionOutOfRange.
Sourcepub const fn max_stack(self, bytes: u32) -> Self
pub const fn max_stack(self, bytes: u32) -> Self
The most stack, in bytes, the stylesheets’ template and function invocations may
use, measured from the start of each stylesheet: beyond it, the validation fails
with Error::Limit (LimitExceeded::Stack) instead of overflowing the
stack, which would abort the process. Default: DEFAULT_MAX_STACK (1.5 MiB), for
the default 2 MiB stack of a spawned thread. The thread that validates must have
this much stack and at least 512 KiB more, for its caller and the deepest
invocation.
On WebAssembly, the default is 256 KiB, and so is the most allowed,
WASM_MAX_STACK: a validation asking for more fails with
Error::OptionOutOfRange.
Sourcepub const fn clock(self, clock: Clock) -> Self
pub const fn clock(self, clock: Clock) -> Self
The clock of the stylesheets: the implicit timezone and the value of
fn:current-dateTime() (read once per validation, as the reference engine reads
it once per transformation). By default, the system clock in UTC; required on
targets without a system clock, such as wasm32-unknown-unknown, where
validating without it fails with Error::Unsupported.
Sourcepub const fn document_uri(self, uri: &'a str) -> Self
pub const fn document_uri(self, uri: &'a str) -> Self
The URI of the document: what document-uri(/) returns in the stylesheets, and
what the SVRL report states in svrl:active-pattern/@documents. For a file,
file_uri gives the URI the reference engine uses.