pub struct RDFParse<RDF>where
RDF: FocusRDF,{ /* private fields */ }Expand description
Execution context for RDF parsing operations.
Holds the RDF graph and provides methods to execute parsers against it. Automatically handles focus management and provides conveniences for common RDF access patterns (properties, lists, type checking).
Implementations§
Source§impl<RDF> RDFParse<RDF>where
RDF: FocusRDF,
impl<RDF> RDFParse<RDF>where
RDF: FocusRDF,
Sourcepub fn with_focus(rdf: RDF, focus_iri: &IriS) -> Self
pub fn with_focus(rdf: RDF, focus_iri: &IriS) -> Self
Creates a context and immediately sets the focus to the given IRI.
Sourcepub fn current_focus(&self) -> Option<&RDF::Term>
pub fn current_focus(&self) -> Option<&RDF::Term>
Gets the current focus node, if set.
Sourcepub fn set_focus_iri(&mut self, iri: &IriS)
pub fn set_focus_iri(&mut self, iri: &IriS)
Sets the focus node from an IRI.
Sourcepub fn restore_focus(&mut self)
pub fn restore_focus(&mut self)
Restores the focus to the initial focus when the context was created.
pub fn rdf_mut(&mut self) -> &mut RDF
Sourcepub fn run<P, T>(&mut self, parser: P) -> Result<T, RDFError>where
P: RDFNodeParse<RDF, Output = T>,
pub fn run<P, T>(&mut self, parser: P) -> Result<T, RDFError>where
P: RDFNodeParse<RDF, Output = T>,
Executes any parser against the current context.
This is the universal entry point - accepts any parser implementing
RDFNodeParse, from simple property extractors to complex compositions.
§Type Parameters
P- The parser typeT- The output type of the parser
Sourcepub fn run_from<P, T>(
&mut self,
start_node: &IriS,
parser: P,
) -> Result<T, RDFError>where
P: RDFNodeParse<RDF, Output = T>,
pub fn run_from<P, T>(
&mut self,
start_node: &IriS,
parser: P,
) -> Result<T, RDFError>where
P: RDFNodeParse<RDF, Output = T>,
Executes a parser starting from a specific node (ignores current focus).
Temporarily sets focus to start_node, executes the parser, then
restores the previous focus.
Sourcepub fn get_property_values(
&mut self,
pred: IriS,
) -> Result<HashSet<RDF::Term>, RDFError>
pub fn get_property_values( &mut self, pred: IriS, ) -> Result<HashSet<RDF::Term>, RDFError>
Gets all values of a property from the current focus node.
Equivalent to ctx.run(ValuesPropertyParser::new(pred)).
Sourcepub fn get_property(&mut self, pred: IriS) -> Result<RDF::Term, RDFError>
pub fn get_property(&mut self, pred: IriS) -> Result<RDF::Term, RDFError>
Gets a single value of a property.
Sourcepub fn get_type(&mut self) -> Result<RDF::Term, RDFError>
pub fn get_type(&mut self) -> Result<RDF::Term, RDFError>
Gets the rdf:type of the current focus node.
Sourcepub fn has_type(&mut self, expected: IriS) -> Result<(), RDFError>
pub fn has_type(&mut self, expected: IriS) -> Result<(), RDFError>
Checks if the current focus has the given type.
Sourcepub fn parse_list(&mut self) -> Result<Vec<RDF::Term>, RDFError>where
RDF: FocusRDF,
pub fn parse_list(&mut self) -> Result<Vec<RDF::Term>, RDFError>where
RDF: FocusRDF,
Parses an RDF list starting at the current focus.
Sourcepub fn get_list_property(
&mut self,
pred: IriS,
) -> Result<Vec<RDF::Term>, RDFError>where
RDF: FocusRDF,
pub fn get_list_property(
&mut self,
pred: IriS,
) -> Result<Vec<RDF::Term>, RDFError>where
RDF: FocusRDF,
Parses an RDF list pointed to by a property.
Sourcepub fn find_instances_of(
&mut self,
type_iri: IriS,
) -> Result<Vec<RDF::Subject>, RDFError>where
RDF: FocusRDF,
pub fn find_instances_of(
&mut self,
type_iri: IriS,
) -> Result<Vec<RDF::Subject>, RDFError>where
RDF: FocusRDF,
Finds all instances of a given type in the entire graph.
This is a graph-wide query, not focus-dependent.