Skip to main content

ParserExt

Trait ParserExt 

Source
pub trait ParserExt<RDF>: RDFNodeParse<RDF> + Sized
where RDF: FocusRDF,
{
Show 15 methods // Provided methods fn map<F, B>(self, f: F) -> Map<Self, F> where F: Fn(Self::Output) -> B { ... } fn and_then<F, O>(self, func: F) -> AndThen<Self, F> where F: Fn(Self::Output) -> Result<O, RDFError> { ... } fn flat_map<F, O>(self, function: F) -> FlatMap<Self, F> where F: Fn(Self::Output) -> Result<O, RDFError> { ... } fn then<F, N>(self, function: F) -> Then<Self, F> where F: Fn(Self::Output) -> N, N: RDFNodeParse<RDF> { ... } fn optional(self) -> Optional<Self> { ... } fn or<P>(self, other: P) -> Or<Self, P> where P: RDFNodeParse<RDF, Output = Self::Output> { ... } fn and<P, B>(self, other: P) -> And<Self, P> where P: RDFNodeParse<RDF, Output = B> { ... } fn not(self) -> Not<Self> where Self::Output: Debug { ... } fn with<P, B>(self, other: P) -> With<Self, P> where P: RDFNodeParse<RDF, Output = B> { ... } fn combine<P, A>(self, other: P) -> Combine<Self, P> where Self: RDFNodeParse<RDF, Output = Vec<A>>, P: RDFNodeParse<RDF, Output = Vec<A>> { ... } fn combine_many<A>( self, others: Vec<Box<dyn RDFNodeParse<RDF, Output = Vec<A>>>>, ) -> CombineMany<RDF, A> where Self: RDFNodeParse<RDF, Output = Vec<A>> + 'static, RDF: 'static { ... } fn for_each(self, nodes: Vec<RDF::Term>) -> ForEach<RDF, Self> where Self: Clone { ... } fn list<A>(self) -> List<RDF, Self> where Self: RDFNodeParse<RDF, Output = A> { ... } fn opaque<F>(f: F) -> Opaque<F, RDF, Self::Output> where F: FnMut(&mut dyn FnMut(&mut dyn RDFNodeParse<RDF, Output = Self::Output>)) { ... } fn map_property(self, property: IriS) -> MapPropertyValuesParser<RDF, Self> where Self: RDFNodeParse<RDF> { ... }
}
Expand description

Extension trait providing fluent combinator methods for parsers.

Automatically implemented for all types implementing RDFNodeParse<RDF>, enabling method chaining for parser composition.

Provided Methods§

Source

fn map<F, B>(self, f: F) -> Map<Self, F>
where F: Fn(Self::Output) -> B,

Transforms successful results using a function.

Source

fn and_then<F, O>(self, func: F) -> AndThen<Self, F>
where F: Fn(Self::Output) -> Result<O, RDFError>,

Chains a fallible transformation after this parser.

Source

fn flat_map<F, O>(self, function: F) -> FlatMap<Self, F>
where F: Fn(Self::Output) -> Result<O, RDFError>,

Chains a fallible transformation (monadic bind).

Source

fn then<F, N>(self, function: F) -> Then<Self, F>
where F: Fn(Self::Output) -> N, N: RDFNodeParse<RDF>,

Creates a dependent parser consuming this parser’s output.

Source

fn optional(self) -> Optional<Self>

Makes the parser optional, converting failure to None.

Source

fn or<P>(self, other: P) -> Or<Self, P>
where P: RDFNodeParse<RDF, Output = Self::Output>,

Provides an alternative parser if this one fails.

Source

fn and<P, B>(self, other: P) -> And<Self, P>
where P: RDFNodeParse<RDF, Output = B>,

Combines this parser with another, returning both results as a tuple.

Source

fn not(self) -> Not<Self>
where Self::Output: Debug,

Negates this parser’s result.

Source

fn with<P, B>(self, other: P) -> With<Self, P>
where P: RDFNodeParse<RDF, Output = B>,

Runs this parser for side effects, then returns the result of another.

Source

fn combine<P, A>(self, other: P) -> Combine<Self, P>
where Self: RDFNodeParse<RDF, Output = Vec<A>>, P: RDFNodeParse<RDF, Output = Vec<A>>,

Combines two vector-producing parsers.

Source

fn combine_many<A>( self, others: Vec<Box<dyn RDFNodeParse<RDF, Output = Vec<A>>>>, ) -> CombineMany<RDF, A>
where Self: RDFNodeParse<RDF, Output = Vec<A>> + 'static, RDF: 'static,

Combines multiple vector-producing parsers by erasing their types into Boxes.

Source

fn for_each(self, nodes: Vec<RDF::Term>) -> ForEach<RDF, Self>
where Self: Clone,

Applies this parser to multiple nodes.

Source

fn list<A>(self) -> List<RDF, Self>
where Self: RDFNodeParse<RDF, Output = A>,

Parses an RDF list using this parser for elements.

Source

fn opaque<F>(f: F) -> Opaque<F, RDF, Self::Output>
where F: FnMut(&mut dyn FnMut(&mut dyn RDFNodeParse<RDF, Output = Self::Output>)),

Wraps dynamic parser dispatch for runtime parser selection.

Source

fn map_property(self, property: IriS) -> MapPropertyValuesParser<RDF, Self>
where Self: RDFNodeParse<RDF>,

Applies this parser to all values of a property.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<RDF, T> ParserExt<RDF> for T
where T: RDFNodeParse<RDF> + Sized, RDF: FocusRDF,