Skip to main content

RDFParse

Struct RDFParse 

Source
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,

Source

pub fn new(rdf: RDF) -> Self

Creates a new parsing context wrapping the RDF graph.

Source

pub fn with_focus(rdf: RDF, focus_iri: &IriS) -> Self

Creates a context and immediately sets the focus to the given IRI.

Source

pub fn prefixmap(&self) -> Option<PrefixMap>

Returns the prefix map of the underlying graph.

Source

pub fn current_focus(&self) -> Option<&RDF::Term>

Gets the current focus node, if set.

Source

pub fn set_focus(&mut self, focus: &RDF::Term)

Sets the focus node to a specific term.

Source

pub fn set_focus_iri(&mut self, iri: &IriS)

Sets the focus node from an IRI.

Source

pub fn restore_focus(&mut self)

Restores the focus to the initial focus when the context was created.

Source

pub fn rdf(&self) -> &RDF

Returns a reference to the underlying RDF graph.

Source

pub fn rdf_mut(&mut self) -> &mut RDF

Source

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 type
  • T - The output type of the parser
Source

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.

Source

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)).

Source

pub fn get_property(&mut self, pred: IriS) -> Result<RDF::Term, RDFError>

Gets a single value of a property.

Source

pub fn get_type(&mut self) -> Result<RDF::Term, RDFError>

Gets the rdf:type of the current focus node.

Source

pub fn has_type(&mut self, expected: IriS) -> Result<(), RDFError>

Checks if the current focus has the given type.

Source

pub fn parse_list(&mut self) -> Result<Vec<RDF::Term>, RDFError>
where RDF: FocusRDF,

Parses an RDF list starting at the current focus.

Source

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.

Source

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.

Source

pub fn find_single_instance( &mut self, type_iri: IriS, ) -> Result<RDF::Subject, RDFError>
where RDF: FocusRDF,

Finds exactly one instance of a type (fails if not exactly one).

Source

pub fn check<F>(&mut self, predicate: F, name: &str) -> Result<(), RDFError>
where F: Fn(&RDF::Term) -> bool,

Validates current focus against a predicate.

Auto Trait Implementations§

§

impl<RDF> Freeze for RDFParse<RDF>
where RDF: Freeze, <RDF as Rdf>::Term: Freeze,

§

impl<RDF> RefUnwindSafe for RDFParse<RDF>
where RDF: RefUnwindSafe, <RDF as Rdf>::Term: RefUnwindSafe,

§

impl<RDF> Send for RDFParse<RDF>
where RDF: Send, <RDF as Rdf>::Term: Send,

§

impl<RDF> Sync for RDFParse<RDF>
where RDF: Sync, <RDF as Rdf>::Term: Sync,

§

impl<RDF> Unpin for RDFParse<RDF>
where RDF: Unpin, <RDF as Rdf>::Term: Unpin,

§

impl<RDF> UnsafeUnpin for RDFParse<RDF>
where RDF: UnsafeUnpin, <RDF as Rdf>::Term: UnsafeUnpin,

§

impl<RDF> UnwindSafe for RDFParse<RDF>
where RDF: UnwindSafe, <RDF as Rdf>::Term: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more