serde_yml::libyml::parser

Struct Parser

Source
pub struct Parser<'input> {
    pub pin: Owned<ParserPinned<'input>>,
}
Expand description

Represents a YAML parser.

The Parser struct is responsible for parsing YAML input and generating a sequence of YAML events. It wraps the underlying libyml parser and provides a safe and convenient interface for parsing YAML documents.

The 'input lifetime parameter indicates the lifetime of the input data being parsed. It ensures that the Parser does not outlive the input data.

Fields§

§pin: Owned<ParserPinned<'input>>

The pinned parser state.

The Owned<ParserPinned<'input>> type represents an owned instance of the ParserPinned struct. The Owned type is used to provide pinning and allows the Parser to be safely moved around.

The ParserPinned struct contains the underlying libyml parser state and the input data being parsed.

Pinning is used to ensure that the Parser remains at a fixed memory location, which is required for safe interaction with the libyml library.

Implementations§

Source§

impl<'input> Parser<'input>

Source

pub fn new(input: Cow<'input, [u8]>) -> Parser<'input>

Creates a new Parser instance with the given input data.

The input parameter is of type Cow<'input, [u8]>, which allows the parser to accept both borrowed slices and owned vectors of bytes as input.

§Panics

This function panics if there is an error initializing the underlying libyml parser.

Source

pub fn parse_next_event(&mut self) -> Result<(Event<'input>, Mark)>

Parses the next YAML event from the input.

Returns a Result containing the parsed Event and its corresponding Mark on success, or an Error if parsing fails.

Source

pub fn is_ok(&self) -> bool

Checks if the parser is initialized and ready to parse YAML.

This function returns true if the parser is initialized and ready to parse YAML, and false otherwise.

Trait Implementations§

Source§

impl<'input> Debug for Parser<'input>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'input> Freeze for Parser<'input>

§

impl<'input> RefUnwindSafe for Parser<'input>

§

impl<'input> !Send for Parser<'input>

§

impl<'input> !Sync for Parser<'input>

§

impl<'input> Unpin for Parser<'input>

§

impl<'input> UnwindSafe for Parser<'input>

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.