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 elementsImplementations§
Source§impl<'doc> TupleParser<'doc>
impl<'doc> TupleParser<'doc>
Sourcepub fn next<T>(&mut self) -> Result<T, T::Error>
pub fn next<T>(&mut self) -> Result<T, T::Error>
Get the next element, advancing the position.
Returns ParseErrorKind::MissingField if no more elements.
Sourcepub fn next_with<T>(&mut self, parser: T) -> Result<T::Output, T::Error>
pub fn next_with<T>(&mut self, parser: T) -> Result<T::Output, T::Error>
Get the next element using a custom parser, advancing the position.
Sourcepub fn next_via<M, T>(&mut self) -> Result<T, M::Error>
pub fn next_via<M, T>(&mut self) -> Result<T, M::Error>
Get the next element using a marker type, advancing the position.
Sourcepub fn get<T>(&self, index: usize) -> Result<T, T::Error>
pub fn get<T>(&self, index: usize) -> Result<T, T::Error>
Get the element at a specific index without advancing position.
Returns ParseErrorKind::MissingField if the index is out of bounds.
Sourcepub fn get_with<T>(
&self,
index: usize,
parser: T,
) -> Result<T::Output, T::Error>
pub fn get_with<T>( &self, index: usize, parser: T, ) -> Result<T::Output, T::Error>
Get the element at a specific index using a custom parser.
Sourcepub fn get_via<M, T>(&self, index: usize) -> Result<T, M::Error>
pub fn get_via<M, T>(&self, index: usize) -> Result<T, M::Error>
Get the element at a specific index using a marker type.
Sourcepub fn finish(self) -> Result<(), ParseError>
pub fn finish(self) -> Result<(), ParseError>
Verify all elements were consumed.
Returns ParseErrorKind::UnexpectedTupleLength if elements remain.
Sourcepub fn expect_len(&self, expected: usize) -> Result<(), ParseError>
pub fn expect_len(&self, expected: usize) -> Result<(), ParseError>
Verify the tuple has the expected length.
Returns ParseErrorKind::UnexpectedTupleLength if length doesn’t match.