CommentPreservingComposer

Struct CommentPreservingComposer 

Source
pub struct CommentPreservingComposer {
    parser: BasicParser,
    scanner: BasicScanner,
    limits: Limits,
    resource_tracker: ResourceTracker,
    anchors: HashMap<String, CommentedValue>,
    current_depth: usize,
    alias_expansion_stack: Vec<String>,
    comment_map: HashMap<Position, String>,
    pending_comments: Vec<String>,
}
Expand description

A composer that preserves comments during parsing

Fields§

§parser: BasicParser§scanner: BasicScanner§limits: Limits§resource_tracker: ResourceTracker§anchors: HashMap<String, CommentedValue>§current_depth: usize§alias_expansion_stack: Vec<String>§comment_map: HashMap<Position, String>

Map of positions to comments (position -> comment text)

§pending_comments: Vec<String>

Stack of pending comments that might belong to the next value

Implementations§

Source§

impl CommentPreservingComposer

Source

pub fn new(input: String) -> Self

Create a new comment-preserving composer

Source

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

Create a new comment-preserving composer with limits

Source

fn extract_comments(&mut self) -> Result<()>

Extract comments from the scanner and build a position map

Source

fn get_comments_for_position(&self, position: Position) -> Comments

Get comments that should be associated with a value at the given position

Source

pub fn compose_document(&mut self) -> Result<Option<CommentedValue>>

Compose a single document with comment preservation

Source

fn compose_node(&mut self) -> Result<Option<CommentedValue>>

Compose a single node (value) with comments

Source

fn compose_scalar( &mut self, value: String, anchor: Option<String>, position: Position, ) -> Result<Option<CommentedValue>>

Compose a scalar value

Source

fn resolve_scalar_type(&self, value: String) -> Value

Resolve scalar type from string value

Source

fn compose_sequence( &mut self, anchor: Option<String>, position: Position, ) -> Result<Option<CommentedValue>>

Compose a sequence

Source

fn compose_mapping( &mut self, anchor: Option<String>, position: Position, ) -> Result<Option<CommentedValue>>

Compose a mapping

Source

fn compose_alias( &mut self, anchor: String, position: Position, ) -> Result<Option<CommentedValue>>

Compose an alias reference

Source

fn collect_item_comments( &self, item: &CommentedValue, inner_comments: &mut Vec<String>, )

Collect comments from a commented value’s comments into inner comments

Source

fn collect_comments( &self, comments: &Comments, inner_comments: &mut Vec<String>, )

Collect comments from a Comments struct into inner comments

Source

fn process_merge_key( &self, mapping: &mut IndexMap<Value, Value>, merge_value: &Value, ) -> Result<()>

Process a merge key by merging values into the current mapping

Trait Implementations§

Source§

impl Debug for CommentPreservingComposer

Source§

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

Formats the value using the given formatter. 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> 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, 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.