Struct serde_yml::libyml::parser::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.