Skip to main content

ValidateOptions

Struct ValidateOptions 

Source
pub struct ValidateOptions<'a> { /* private fields */ }
Expand description

Options of one validation.

Implementations§

Source§

impl<'a> ValidateOptions<'a>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<'a> Clone for ValidateOptions<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for ValidateOptions<'a>

Source§

impl<'a> Debug for ValidateOptions<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ValidateOptions<'_>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Forget for ValidateOptions<'a>

§

impl<'a> Freeze for ValidateOptions<'a>

§

impl<'a> RefUnwindSafe for ValidateOptions<'a>

§

impl<'a> Send for ValidateOptions<'a>

§

impl<'a> Sync for ValidateOptions<'a>

§

impl<'a> Unpin for ValidateOptions<'a>

§

impl<'a> UnsafeUnpin for ValidateOptions<'a>

§

impl<'a> UnwindSafe for ValidateOptions<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.