Skip to main content

LoadOptions

Struct LoadOptions 

Source
pub struct LoadOptions { /* private fields */ }
Expand description

Options for loading YAML into constructed trees or Serde values.

Implementations§

Source§

impl LoadOptions

Source

pub const fn new() -> Self

Creates default load options.

Source

pub const fn core() -> Self

Creates load options using explicit YAML 1.2 Core-compatible construction.

Source

pub const fn json() -> Self

Creates load options using YAML 1.2 JSON schema construction.

Source

pub const fn failsafe() -> Self

Creates load options using YAML Failsafe construction.

Source

pub const fn yaml_1_1() -> Self

Creates load options using explicit YAML 1.1 compatibility construction.

Source

pub const fn legacy_serde_yaml() -> Self

Creates load options using legacy libyaml/serde_yaml-era construction.

Source

pub const fn yaml_version_directive() -> Self

Creates load options that follow each document’s %YAML version directive.

%YAML 1.1 documents use YAML 1.1 compatibility construction. Documents without a version directive, with %YAML 1.2, or with newer numeric versions use the YAML 1.2-oriented default construction.

Source

pub const fn schema(self, schema: Schema) -> Self

Returns options with the selected scalar construction schema.

Source

pub const fn selected_schema(self) -> Schema

Returns the selected scalar construction schema.

Source

pub const fn max_input_bytes(self, max_input_bytes: usize) -> Self

Returns options with a maximum input size in bytes.

Source

pub const fn without_input_limit(self) -> Self

Returns options without an input size limit.

Source

pub const fn selected_max_input_bytes(self) -> Option<usize>

Returns the configured maximum input size in bytes.

Source

pub const fn max_alias_expansion_nodes( self, max_alias_expansion_nodes: usize, ) -> Self

Returns options with a maximum number of alias-expanded nodes.

The default budget remains input-size derived. This option lets callers loading untrusted configuration tighten that expansion work directly.

Source

pub const fn selected_max_alias_expansion_nodes(self) -> Option<usize>

Returns the configured maximum number of alias-expanded nodes.

None means the default input-size-derived budget is selected.

Source

pub const fn max_nesting_depth(self, max_nesting_depth: usize) -> Self

Returns options with a maximum constructed YAML nesting depth.

Source

pub const fn without_nesting_depth_limit(self) -> Self

Returns options without a constructed nesting-depth limit.

Disabling the nesting-depth limit also removes protection against stack overflow: adversarially deep alias chains or nested flow collections can recurse until the thread’s stack is exhausted and the process aborts. Only disable the limit for trusted input.

Source

pub const fn selected_max_nesting_depth(self) -> Option<usize>

Returns the configured maximum constructed nesting depth.

Source

pub const fn max_scalar_bytes(self, max_scalar_bytes: usize) -> Self

Returns options with a maximum resolved scalar size in bytes.

Source

pub const fn without_scalar_limit(self) -> Self

Returns options without a resolved scalar-size limit.

Source

pub const fn selected_max_scalar_bytes(self) -> Option<usize>

Returns the configured maximum resolved scalar size in bytes.

Source

pub const fn max_collection_items(self, max_collection_items: usize) -> Self

Returns options with a maximum number of entries per sequence or mapping.

Source

pub const fn without_collection_limit(self) -> Self

Returns options without a per-collection item limit.

Source

pub const fn selected_max_collection_items(self) -> Option<usize>

Returns the configured maximum number of entries per sequence or mapping.

Source

pub fn parse_bytes(self, input: &[u8]) -> Result<Node>

Parses a single UTF-8 YAML document from bytes using these options.

Source

pub fn parse_str(self, input: &str) -> Result<Node>

Parses a single YAML document from a string using these options.

Source

pub fn parse_documents(self, input: &str) -> Result<Vec<Node>>

Parses all documents in a YAML stream using these options.

Source

pub fn parse_borrowed_documents<'de>( self, input: &'de str, ) -> Result<Vec<BorrowedNode<'de>>>

Parses all documents into spanless trees that can borrow scalar strings from input.

Source

pub fn stream_events(self, input: &str) -> Result<EventStream>

Creates a pull-based raw event stream using these options.

Source

pub fn stream_events_slice(self, input: &[u8]) -> Result<EventStream>

Creates a pull-based raw event stream from UTF-8 bytes using these options.

Source

pub fn stream_events_reader<R>(self, reader: R) -> Result<EventStream>
where R: Read,

Reads YAML bytes and creates a pull-based raw event stream using these options.

Source

pub fn stream_documents(self, input: &str) -> Result<DocumentStream>

Creates a pull-based parsed document stream using these options.

Source

pub fn stream_documents_slice(self, input: &[u8]) -> Result<DocumentStream>

Creates a pull-based parsed document stream from UTF-8 bytes using these options.

Source

pub fn stream_documents_reader<R>(self, reader: R) -> Result<DocumentStream>
where R: Read,

Reads YAML bytes and creates a pull-based parsed document stream using these options.

Source

pub fn from_str<'de, T>(self, input: &'de str) -> Result<T>
where T: Deserialize<'de>,

Deserializes a single YAML document from a string using these options.

Source

pub fn from_slice<'de, T>(self, input: &'de [u8]) -> Result<T>
where T: Deserialize<'de>,

Deserializes a single UTF-8 YAML document from bytes using these options.

Source

pub fn from_reader<R, T>(self, reader: R) -> Result<T>
where R: Read, T: DeserializeOwned,

Reads all bytes from a reader and deserializes one YAML document.

Source

pub fn from_documents_str<T>(self, input: &str) -> Result<Vec<T>>

Deserializes every document in a YAML stream from a string.

Source

pub fn from_documents_slice<T>(self, input: &[u8]) -> Result<Vec<T>>

Deserializes every document in a UTF-8 YAML stream from bytes.

Source

pub fn from_documents_reader<T, R>(self, reader: R) -> Result<Vec<T>>
where T: DeserializeOwned, R: Read,

Reads all bytes from a reader and deserializes every YAML document.

Source

pub fn deserializer_from_str<'de>(self, input: &'de str) -> Deserializer<'de>

Creates a streaming Serde deserializer from a YAML string.

Source

pub fn deserializer_from_slice<'de>(self, input: &'de [u8]) -> Deserializer<'de>

Creates a streaming Serde deserializer from UTF-8 YAML bytes.

Source

pub fn deserializer_from_reader<R>(self, reader: R) -> Deserializer<'static>
where R: Read,

Reads a YAML stream and creates a streaming Serde deserializer.

Trait Implementations§

Source§

impl Clone for LoadOptions

Source§

fn clone(&self) -> LoadOptions

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 LoadOptions

Source§

impl Debug for LoadOptions

Source§

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

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

impl Default for LoadOptions

Source§

fn default() -> Self

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

impl Eq for LoadOptions

Source§

impl PartialEq for LoadOptions

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for LoadOptions

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