Skip to main content

YamlReadOptions

Struct YamlReadOptions 

Source
#[non_exhaustive]
pub struct YamlReadOptions { pub max_alias_expansion: u32, pub max_expanded_slots: u32, pub limits: Limits, }
Expand description

Options for read_yaml_with.

use omnist::formats::yaml::{read_yaml_with, YamlReadOptions};

let opts = YamlReadOptions::default().with_max_alias_expansion(200);
let doc = read_yaml_with("a: 1\n", &opts).unwrap();
assert_eq!(doc.to_raw(), omnist::formats::yaml::read_yaml("a: 1\n").unwrap().to_raw());

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§max_alias_expansion: u32

The maximum alias expansion factor E = W / S any one mapping or sequence (anchored or not, the document root included) may reach before the reader rejects the input with document.limit.alias-expansion (spec §2.4.1, D-18).

0 selects DEFAULT_MAX_ALIAS_EXPANSION (50): a zero or unset value never widens the limit. Values above MAX_ALIAS_EXPANSION_CEILING (10 000) are rejected by read_yaml_with. Note the (keys + 2) / 3 behaviour of merges: a mapping that merges an n-key anchor and writes one key of its own has E ~ (n + 2) / 3, so the default of 50 rejects merging a 150-key anchor into such a mapping; raise this option for configurations that large.

§max_expanded_slots: u32

The maximum expanded size W(root), in value slots, an input that contains at least one alias or merge key may reach before the reader rejects it with document.limit.expanded-size (spec §2.4.1, D-22). W(root) equal to the maximum is accepted; one past is rejected.

This is independent of YamlReadOptions::max_alias_expansion: the ratio limit bounds amplification, this one bounds absolute size, and an input can pass one and fail the other (when both fail the ratio code is reported). An input with neither an alias nor a merge key is exempt however large: a plain file of two million slots passes, and adding one alias subjects it to this cap. 0 selects DEFAULT_MAX_EXPANDED_SLOTS (1 000 000); values above MAX_EXPANDED_SLOTS_CEILING (10 000 000) are rejected by read_yaml_with.

§limits: Limits

The safety limits every format shares (nesting depth, node count, integer digits; spec section 2.4): see Limits.

Implementations§

Source§

impl YamlReadOptions

Source

pub fn with_max_alias_expansion(self, n: u32) -> Self

These options with YamlReadOptions::max_alias_expansion set to n (the struct is #[non_exhaustive], so a downstream crate builds it from Default with this).

Source

pub fn with_max_expanded_slots(self, n: u32) -> Self

These options with YamlReadOptions::max_expanded_slots set to n.

Source

pub fn with_limits(self, limits: Limits) -> Self

These options with YamlReadOptions::limits set to limits.

Source

pub fn effective_max_expanded_slots(&self) -> u32

The maximum expanded size these options select: the configured value, or DEFAULT_MAX_EXPANDED_SLOTS when it is 0.

Source

pub fn effective_max_alias_expansion(&self) -> u32

The maximum expansion factor these options select: the configured value, or DEFAULT_MAX_ALIAS_EXPANSION when it is 0.

Source

pub fn validate(&self) -> Result<(), DocumentError>

Trait Implementations§

Source§

impl Clone for YamlReadOptions

Source§

fn clone(&self) -> YamlReadOptions

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 Copy for YamlReadOptions

Source§

impl Debug for YamlReadOptions

Source§

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

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

impl Default for YamlReadOptions

Source§

fn default() -> Self

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

impl Eq for YamlReadOptions

Source§

impl PartialEq for YamlReadOptions

Source§

fn eq(&self, other: &YamlReadOptions) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for YamlReadOptions

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.