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§
Provided Methods§
Sourcefn and<U, P>(self, other: P) -> And<Self, P, T, U>
fn and<U, P>(self, other: P) -> And<Self, P, T, U>
Combine this parser with another, applying both and combining results
Sourcefn filter(self) -> Filter<Self>where
Self: Sized,
fn filter(self) -> Filter<Self>where
Self: Sized,
Turns the input into an optional output if the provided parser succeeds
Sourcefn map<U, F>(self, f: F) -> Map<Self, F, T>
fn map<U, F>(self, f: F) -> Map<Self, F, T>
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
.