Trait Parser

Source
pub trait Parser<T> {
    // Required method
    fn parse(&self, db: &dyn DwarfDb, entry: Die) -> Result<T>;

    // Provided methods
    fn and<U, P>(self, other: P) -> And<Self, P, T, U>
       where Self: Sized,
             P: Parser<U> { ... }
    fn filter(self) -> Filter<Self>
       where Self: Sized { ... }
    fn map<U, F>(self, f: F) -> Map<Self, F, T>
       where Self: Sized,
             F: Fn(T) -> U { ... }
    fn map_with_entry<U, F>(self, f: F) -> MapWithDbAndEntry<Self, F, T>
       where Self: Sized,
             F: Fn(&dyn DwarfDb, Die, T) -> U { ... }
    fn map_res<U, F>(self, f: F) -> MapRes<Self, F, T>
       where Self: Sized,
             F: Fn(T) -> Result<U> { ... }
    fn then<U, P, V>(self, next: P) -> Then<Self, P, V>
       where Self: Sized + Parser<V>,
             P: Parser<U> { ... }
    fn context<S: Into<String>>(self, ctx: S) -> Context<Self>
       where Self: Sized { ... }
}
Expand description

Core parser trait that all combinators implement

Required Methods§

Source

fn parse(&self, db: &dyn DwarfDb, entry: Die) -> Result<T>

Provided Methods§

Source

fn and<U, P>(self, other: P) -> And<Self, P, T, U>
where Self: Sized, P: Parser<U>,

Combine this parser with another, applying both and combining results

Source

fn filter(self) -> Filter<Self>
where Self: Sized,

Turns the input into an optional output if the provided parser succeeds

Source

fn map<U, F>(self, f: F) -> Map<Self, F, T>
where Self: Sized, F: Fn(T) -> U,

Transform the output of this parser

Supports both simple transformations.

For more complex transformations that require access to the database or entry, use map_with_db or map_with_db_and_entry.

Source

fn map_with_entry<U, F>(self, f: F) -> MapWithDbAndEntry<Self, F, T>
where Self: Sized, F: Fn(&dyn DwarfDb, Die, T) -> U,

Source

fn map_res<U, F>(self, f: F) -> MapRes<Self, F, T>
where Self: Sized, F: Fn(T) -> Result<U>,

Transform the output of this parser

Source

fn then<U, P, V>(self, next: P) -> Then<Self, P, V>
where Self: Sized + Parser<V>, P: Parser<U>,

Chain this parser with another, where the second operates on the first’s result

Source

fn context<S: Into<String>>(self, ctx: S) -> Context<Self>
where Self: Sized,

Add context to errors from this parser

Implementations on Foreign Types§

Source§

impl<T, P> Parser<T> for &P
where P: Parser<T>,

Source§

fn parse(&self, db: &dyn DwarfDb, entry: Die) -> Result<T>

Implementors§

Source§

impl Parser<(Die, usize)> for FieldPath

Source§

impl Parser<Option<String>> for Attr<Option<String>>

Source§

impl Parser<AttributeValue<EndianReader<LittleEndian, OwnedOrBorrowed>>> for Attr<AttributeValue<EndianReader<LittleEndian, OwnedOrBorrowed>>>

Source§

impl Parser<i64> for Attr<i64>

Source§

impl Parser<i128> for Attr<i128>

Source§

impl Parser<u64> for Attr<u64>

Source§

impl Parser<()> for ParseChildren<()>

Source§

impl Parser<()> for All<()>

Source§

impl Parser<usize> for Attr<usize>

Source§

impl Parser<usize> for DataOffset

Source§

impl Parser<usize> for IsMemberOffset

Source§

impl Parser<Die> for Attr<Die>

Source§

impl Parser<Die> for Generic

Source§

impl Parser<Die> for Identity

Source§

impl Parser<Die> for IsMember

Source§

impl Parser<Die> for IsMemberTag

Source§

impl Parser<Die> for Member

Source§

impl Parser<Die> for MemberByTag

Source§

impl Parser<String> for Attr<String>

Source§

impl Parser<DwLang> for Attr<DwLang>

Source§

impl Parser<EnumLayout<Die>> for EnumParser

Source§

impl Parser<MapLayout<Die>> for BTreeMapParser

Source§

impl Parser<OptionLayout<Die>> for OptionDefParser

Source§

impl Parser<ResultLayout<Die>> for ResultDefParser

Source§

impl Parser<TypeDefinition<Die>> for ResolveType

Source§

impl Parser<TypeDefinition<Die>> for ResolveTypeShallow

Source§

impl<'db> Parser<(Option<usize>, ())> for EnumNamedTupleVariant<()>

Source§

impl<'db, T0, P0> Parser<(Option<usize>, ((usize, T0),))> for EnumNamedTupleVariant<(P0,)>
where P0: Parser<T0>,

Source§

impl<'db, T0, P0, T1, P1> Parser<(Option<usize>, ((usize, T0), (usize, T1)))> for EnumNamedTupleVariant<(P0, P1)>
where P0: Parser<T0>, P1: Parser<T1>,

Source§

impl<'db, T0, P0, T1, P1, T2, P2> Parser<(Option<usize>, ((usize, T0), (usize, T1), (usize, T2)))> for EnumNamedTupleVariant<(P0, P1, P2)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>,

Source§

impl<'db, T0, P0, T1, P1, T2, P2, T3, P3> Parser<(Option<usize>, ((usize, T0), (usize, T1), (usize, T2), (usize, T3)))> for EnumNamedTupleVariant<(P0, P1, P2, P3)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>, P3: Parser<T3>,

Source§

impl<'db, T0, P0, T1, P1, T2, P2, T3, P3, T4, P4> Parser<(Option<usize>, ((usize, T0), (usize, T1), (usize, T2), (usize, T3), (usize, T4)))> for EnumNamedTupleVariant<(P0, P1, P2, P3, P4)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>, P3: Parser<T3>, P4: Parser<T4>,

Source§

impl<'db, T0, P0, T1, P1, T2, P2, T3, P3, T4, P4, T5, P5> Parser<(Option<usize>, ((usize, T0), (usize, T1), (usize, T2), (usize, T3), (usize, T4), (usize, T5)))> for EnumNamedTupleVariant<(P0, P1, P2, P3, P4, P5)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>, P3: Parser<T3>, P4: Parser<T4>, P5: Parser<T5>,

Source§

impl<'db, T0, P0, T1, P1, T2, P2, T3, P3, T4, P4, T5, P5, T6, P6> Parser<(Option<usize>, ((usize, T0), (usize, T1), (usize, T2), (usize, T3), (usize, T4), (usize, T5), (usize, T6)))> for EnumNamedTupleVariant<(P0, P1, P2, P3, P4, P5, P6)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>, P3: Parser<T3>, P4: Parser<T4>, P5: Parser<T5>, P6: Parser<T6>,

Source§

impl<'db, T0, P0, T1, P1, T2, P2, T3, P3, T4, P4, T5, P5, T6, P6, T7, P7> Parser<(Option<usize>, ((usize, T0), (usize, T1), (usize, T2), (usize, T3), (usize, T4), (usize, T5), (usize, T6), (usize, T7)))> for EnumNamedTupleVariant<(P0, P1, P2, P3, P4, P5, P6, P7)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>, P3: Parser<T3>, P4: Parser<T4>, P5: Parser<T5>, P6: Parser<T6>, P7: Parser<T7>,

Source§

impl<T0, P0> Parser<(T0,)> for ParseChildren<(P0,)>
where P0: Parser<T0>,

Source§

impl<T0, P0> Parser<(T0,)> for All<(P0,)>
where P0: Parser<T0>,

Source§

impl<T0, P0, T1, P1> Parser<(T0, T1)> for ParseChildren<(P0, P1)>
where P0: Parser<T0>, P1: Parser<T1>,

Source§

impl<T0, P0, T1, P1> Parser<(T0, T1)> for All<(P0, P1)>
where P0: Parser<T0>, P1: Parser<T1>,

Source§

impl<T0, P0, T1, P1, T2, P2> Parser<(T0, T1, T2)> for ParseChildren<(P0, P1, P2)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>,

Source§

impl<T0, P0, T1, P1, T2, P2> Parser<(T0, T1, T2)> for All<(P0, P1, P2)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>,

Source§

impl<T0, P0, T1, P1, T2, P2, T3, P3> Parser<(T0, T1, T2, T3)> for ParseChildren<(P0, P1, P2, P3)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>, P3: Parser<T3>,

Source§

impl<T0, P0, T1, P1, T2, P2, T3, P3> Parser<(T0, T1, T2, T3)> for All<(P0, P1, P2, P3)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>, P3: Parser<T3>,

Source§

impl<T0, P0, T1, P1, T2, P2, T3, P3, T4, P4> Parser<(T0, T1, T2, T3, T4)> for ParseChildren<(P0, P1, P2, P3, P4)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>, P3: Parser<T3>, P4: Parser<T4>,

Source§

impl<T0, P0, T1, P1, T2, P2, T3, P3, T4, P4> Parser<(T0, T1, T2, T3, T4)> for All<(P0, P1, P2, P3, P4)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>, P3: Parser<T3>, P4: Parser<T4>,

Source§

impl<T0, P0, T1, P1, T2, P2, T3, P3, T4, P4, T5, P5> Parser<(T0, T1, T2, T3, T4, T5)> for ParseChildren<(P0, P1, P2, P3, P4, P5)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>, P3: Parser<T3>, P4: Parser<T4>, P5: Parser<T5>,

Source§

impl<T0, P0, T1, P1, T2, P2, T3, P3, T4, P4, T5, P5> Parser<(T0, T1, T2, T3, T4, T5)> for All<(P0, P1, P2, P3, P4, P5)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>, P3: Parser<T3>, P4: Parser<T4>, P5: Parser<T5>,

Source§

impl<T0, P0, T1, P1, T2, P2, T3, P3, T4, P4, T5, P5, T6, P6> Parser<(T0, T1, T2, T3, T4, T5, T6)> for ParseChildren<(P0, P1, P2, P3, P4, P5, P6)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>, P3: Parser<T3>, P4: Parser<T4>, P5: Parser<T5>, P6: Parser<T6>,

Source§

impl<T0, P0, T1, P1, T2, P2, T3, P3, T4, P4, T5, P5, T6, P6> Parser<(T0, T1, T2, T3, T4, T5, T6)> for All<(P0, P1, P2, P3, P4, P5, P6)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>, P3: Parser<T3>, P4: Parser<T4>, P5: Parser<T5>, P6: Parser<T6>,

Source§

impl<T0, P0, T1, P1, T2, P2, T3, P3, T4, P4, T5, P5, T6, P6, T7, P7> Parser<(T0, T1, T2, T3, T4, T5, T6, T7)> for ParseChildren<(P0, P1, P2, P3, P4, P5, P6, P7)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>, P3: Parser<T3>, P4: Parser<T4>, P5: Parser<T5>, P6: Parser<T6>, P7: Parser<T7>,

Source§

impl<T0, P0, T1, P1, T2, P2, T3, P3, T4, P4, T5, P5, T6, P6, T7, P7> Parser<(T0, T1, T2, T3, T4, T5, T6, T7)> for All<(P0, P1, P2, P3, P4, P5, P6, P7)>
where P0: Parser<T0>, P1: Parser<T1>, P2: Parser<T2>, P3: Parser<T3>, P4: Parser<T4>, P5: Parser<T5>, P6: Parser<T6>, P7: Parser<T7>,

Source§

impl<T> Parser<Option<T>> for OptionalAttr<T>
where Attr<T>: Parser<T>,

Source§

impl<T, F, E> Parser<T> for FromFn<F>
where F: Fn(&dyn DwarfDb, Die) -> Result<T, E>, E: Into<Error>,

Source§

impl<T, P> Parser<Option<T>> for Filter<P>
where P: Parser<T>,

Source§

impl<T, P> Parser<Vec<T>> for ForEachChild<P>
where P: Parser<T>,

Source§

impl<T, P> Parser<Vec<T>> for TryForEachChild<P>
where P: Parser<Option<T>>,

Source§

impl<T, P> Parser<T> for Context<P>
where P: Parser<T>,

Source§

impl<T, U, P1, P2> Parser<(T, U)> for And<P1, P2, T, U>
where P1: Parser<T>, P2: Parser<U>,

Source§

impl<T, U, P, F> Parser<U> for Map<P, F, T>
where P: Parser<T>, F: Fn(T) -> U,

Source§

impl<T, U, P, F> Parser<U> for MapRes<P, F, T>
where P: Parser<T>, F: Fn(T) -> Result<U>,

Source§

impl<T, U, P, F> Parser<U> for MapWithDb<P, F, T>
where P: Parser<T>, F: Fn(&dyn DwarfDb, T) -> U,

Source§

impl<T, U, P, F> Parser<U> for MapWithDbAndEntry<P, F, T>
where P: Parser<T>, F: Fn(&dyn DwarfDb, Die, T) -> U,

Source§

impl<U, P1, P2> Parser<Option<U>> for Then<P1, P2, Option<Die>>
where P1: Parser<Option<Die>>, P2: Parser<U>,

Source§

impl<U, P1, P2> Parser<U> for Then<P1, P2, Die>
where P1: Parser<Die>, P2: Parser<U>,

Source§

impl<U, P1, P2> Parser<U> for Then<P1, P2, Result<Die>>
where P1: Parser<Result<Die>>, P2: Parser<U>,