#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.max_alias_expansion: u32The 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: u32The 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: LimitsThe safety limits every format shares (nesting depth, node count,
integer digits; spec section 2.4): see Limits.
Implementations§
Source§impl YamlReadOptions
impl YamlReadOptions
Sourcepub fn with_max_alias_expansion(self, n: u32) -> Self
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).
Sourcepub fn with_max_expanded_slots(self, n: u32) -> Self
pub fn with_max_expanded_slots(self, n: u32) -> Self
These options with YamlReadOptions::max_expanded_slots set to n.
Sourcepub fn with_limits(self, limits: Limits) -> Self
pub fn with_limits(self, limits: Limits) -> Self
These options with YamlReadOptions::limits set to limits.
Sourcepub fn effective_max_expanded_slots(&self) -> u32
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.
Sourcepub fn effective_max_alias_expansion(&self) -> u32
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.
Sourcepub fn validate(&self) -> Result<(), DocumentError>
pub fn validate(&self) -> Result<(), DocumentError>
Checks the options: YamlReadOptions::max_alias_expansion must not
exceed MAX_ALIAS_EXPANSION_CEILING, nor
YamlReadOptions::max_expanded_slots MAX_EXPANDED_SLOTS_CEILING,
and YamlReadOptions::limits must pass Limits::validate.
read_yaml_with calls this
first and returns its error unchanged.
Trait Implementations§
Source§impl Clone for YamlReadOptions
impl Clone for YamlReadOptions
Source§fn clone(&self) -> YamlReadOptions
fn clone(&self) -> YamlReadOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for YamlReadOptions
Source§impl Debug for YamlReadOptions
impl Debug for YamlReadOptions
Source§impl Default for YamlReadOptions
impl Default for YamlReadOptions
impl Eq for YamlReadOptions
Source§impl PartialEq for YamlReadOptions
impl PartialEq for YamlReadOptions
impl StructuralPartialEq for YamlReadOptions
Auto Trait Implementations§
impl Freeze for YamlReadOptions
impl RefUnwindSafe for YamlReadOptions
impl Send for YamlReadOptions
impl Sync for YamlReadOptions
impl Unpin for YamlReadOptions
impl UnsafeUnpin for YamlReadOptions
impl UnwindSafe for YamlReadOptions
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.