Skip to main content

TupleParser

Struct TupleParser 

Source
pub struct TupleParser<'doc> { /* private fields */ }
Expand description

Helper for parsing tuple types from Eure documents.

Provides both sequential access via next() and random access via get(). Use finish() to verify all elements were consumed.

§Example

ⓘ
let mut tuple = ctx.parse_tuple()?;
let first: String = tuple.next()?;
let second: i32 = tuple.next()?;
tuple.finish()?; // Ensures no extra elements

Implementations§

Source§

impl<'doc> TupleParser<'doc>

Source

pub fn node_id(&self) -> NodeId

Get the node ID being parsed.

Source

pub fn next<T>(&mut self) -> Result<T, T::Error>
where T: FromEure<'doc>, T::Error: From<ParseError>,

Get the next element, advancing the position.

Returns ParseErrorKind::MissingField if no more elements.

Source

pub fn next_with<T>(&mut self, parser: T) -> Result<T::Output, T::Error>
where T: DocumentParser<'doc>, T::Error: From<ParseError>,

Get the next element using a custom parser, advancing the position.

Source

pub fn next_via<M, T>(&mut self) -> Result<T, M::Error>
where M: FromEure<'doc, T>, M::Error: From<ParseError>,

Get the next element using a marker type, advancing the position.

Source

pub fn get<T>(&self, index: usize) -> Result<T, T::Error>
where T: FromEure<'doc>, T::Error: From<ParseError>,

Get the element at a specific index without advancing position.

Returns ParseErrorKind::MissingField if the index is out of bounds.

Source

pub fn get_with<T>( &self, index: usize, parser: T, ) -> Result<T::Output, T::Error>
where T: DocumentParser<'doc>, T::Error: From<ParseError>,

Get the element at a specific index using a custom parser.

Source

pub fn get_via<M, T>(&self, index: usize) -> Result<T, M::Error>
where M: FromEure<'doc, T>, M::Error: From<ParseError>,

Get the element at a specific index using a marker type.

Source

pub fn remaining(&self) -> usize

Get the number of remaining elements.

Source

pub fn finish(self) -> Result<(), ParseError>

Verify all elements were consumed.

Returns ParseErrorKind::UnexpectedTupleLength if elements remain.

Source

pub fn expect_len(&self, expected: usize) -> Result<(), ParseError>

Verify the tuple has the expected length.

Returns ParseErrorKind::UnexpectedTupleLength if length doesn’t match.

Source

pub fn len(&self) -> usize

Get the total number of elements in the tuple.

Source

pub fn is_empty(&self) -> bool

Check if the tuple is empty.

Trait Implementations§

Source§

impl<'doc> Debug for TupleParser<'doc>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'doc> Freeze for TupleParser<'doc>

§

impl<'doc> RefUnwindSafe for TupleParser<'doc>

§

impl<'doc> Send for TupleParser<'doc>

§

impl<'doc> Sync for TupleParser<'doc>

§

impl<'doc> Unpin for TupleParser<'doc>

§

impl<'doc> UnsafeUnpin for TupleParser<'doc>

§

impl<'doc> UnwindSafe for TupleParser<'doc>

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

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.