Skip to main content

Document

Struct Document 

Source
pub struct Document<Loc = Span> {
    pub root: Node<Loc>,
    pub version: Option<(u8, u8)>,
    pub tags: Vec<(String, String)>,
    pub comments: Vec<String>,
    pub explicit_start: bool,
    pub explicit_end: bool,
    /* private fields */
}
Expand description

A YAML document: a root node plus directive metadata.

Fields§

§root: Node<Loc>

The root node of the document.

§version: Option<(u8, u8)>

YAML version declared by a %YAML directive, if present (e.g. (1, 2)).

§tags: Vec<(String, String)>

Tag handle/prefix pairs declared by %TAG directives (handle, prefix).

§comments: Vec<String>

Comments that appear at document level (before or between nodes).

§explicit_start: bool

Whether the document was introduced with an explicit --- marker.

§explicit_end: bool

Whether the document was closed with an explicit ... marker.

Implementations§

Source§

impl<Loc> Document<Loc>

Source

pub const fn with_root(root: Node<Loc>) -> Self

Construct a document with the given root node and all metadata set to their default values.

This constructor is intended for unit tests that synthesise AST nodes without going through the loader. The line_index is set to None; calling line_index() on the resulting document will panic.

Source§

impl Document<Span>

Source

pub fn line_index(&self) -> &LineIndex

Return the LineIndex for this document, used to resolve byte offsets from Span values to (line, column) pairs.

§Panics

Panics if the document was not created by the loader (i.e., line_index is None). All documents returned by load() or Loader::load() have a LineIndex set.

Trait Implementations§

Source§

impl<Loc: Clone> Clone for Document<Loc>

Source§

fn clone(&self) -> Document<Loc>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<Loc: Debug> Debug for Document<Loc>

Source§

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

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

impl<Loc: PartialEq> PartialEq for Document<Loc>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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.

Auto Trait Implementations§

§

impl<Loc> Freeze for Document<Loc>
where Loc: Freeze,

§

impl<Loc> RefUnwindSafe for Document<Loc>
where Loc: RefUnwindSafe,

§

impl<Loc> Send for Document<Loc>
where Loc: Send,

§

impl<Loc> Sync for Document<Loc>
where Loc: Sync,

§

impl<Loc> Unpin for Document<Loc>
where Loc: Unpin,

§

impl<Loc> UnsafeUnpin for Document<Loc>
where Loc: UnsafeUnpin,

§

impl<Loc> UnwindSafe for Document<Loc>
where Loc: UnwindSafe,

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.