Skip to main content

CompileOptions

Struct CompileOptions 

Source
pub struct CompileOptions {
    pub default_dialect: Dialect,
    pub assert_format: Option<bool>,
    pub assert_format_in_legacy_drafts: bool,
    pub assert_content: bool,
    pub formats: HashMap<String, FormatValidator>,
    pub resolve_document: Option<DocumentResolver>,
    pub base_uri: Option<String>,
    pub entry_point: Option<String>,
    pub max_depth: u32,
    pub pattern_match_limit: Option<Duration>,
}
Expand description

Options for compiling a schema.

Fields§

§default_dialect: Dialect

The dialect for documents without $schema. Defaults to 2020-12.

§assert_format: Option<bool>

Whether format is asserted. None (the default) follows the vocabularies: the 2020-12 format-assertion vocabulary asserts, everything else annotates.

§assert_format_in_legacy_drafts: bool

When assert_format is None, assert format in draft 4 to 7 too.

§assert_content: bool

Assert contentEncoding/contentMediaType in draft 7 (the only draft that asserts them). Defaults to true.

§formats: HashMap<String, FormatValidator>

Custom format assertions, by format name; they take precedence over the built-in set.

§resolve_document: Option<DocumentResolver>

Resolves remote documents. The standard metaschemas are always available.

§base_uri: Option<String>

The base URI of the root document.

§entry_point: Option<String>

A reference (relative to the root) to evaluate from, e.g. #/$defs/item. Defaults to the root.

§max_depth: u32

Maximum depth of in-place recursion on a cycle before evaluation is abandoned. Defaults to 128.

§pattern_match_limit: Option<Duration>

The time one match of a pattern or patternProperties regular expression against one string may take. Defaults to DEFAULT_PATTERN_MATCH_LIMIT, one second. A match that takes longer is abandoned, and the validation it belongs to reports a PatternMatchLimitError. None, or a limit of zero, turns the limit off, for a caller who trusts both the schema and the instances. Without the limit a match also has no limit on its memory.

The limit is on each match, not on the validation. Only the backtracking matcher can take long, and it reads the clock every 4,096 steps, so a match is abandoned within tens of microseconds of the limit. The matchers that take time proportional to the string are not stopped: a string is given to one only when it can answer within the limit.

Trait Implementations§

Source§

impl Clone for CompileOptions

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 Debug for CompileOptions

Source§

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

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

impl Default for CompileOptions

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> 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.