pub trait FocusRDF: NeighsRDFwhere
Self: 'static,{
// Required methods
fn set_focus(&mut self, focus: &Self::Term);
fn get_focus(&self) -> Option<&Self::Term>;
// Provided methods
fn get_focus_as_term(&self) -> Result<&Self::Term, RDFError> { ... }
fn get_focus_as_subject(&self) -> Result<Self::Subject, RDFError> { ... }
fn get_path_for(
&mut self,
subject: &Self::Term,
predicate: &Self::IRI,
) -> Result<Option<SHACLPath>, RDFError> { ... }
}Expand description
A trait for RDF graphs that maintain a focus node for context-aware parsing.
FocusRDF extends NeighsRDF by adding the concept of a “focus node” - a current
point of reference within the RDF graph. This focus node serves as the starting point
for parsing operations, allowing parsers to navigate the graph structure from a specific
node without repeatedly specifying it.
The focus node pattern is commonly used in RDF validation (like SHACL) and graph traversal scenarios where operations are performed relative to a particular node.
Required Methods§
Provided Methods§
Sourcefn get_focus_as_term(&self) -> Result<&Self::Term, RDFError>
fn get_focus_as_term(&self) -> Result<&Self::Term, RDFError>
Retrieves the current focus node as a term, failing if no focus is set.
This is a convenience method that unwraps the focus option and returns an error if no focus node is currently set. Useful when a focus is required for an operation to proceed.
§Returns
Ok(&term)- A reference to the current focus nodeErr(RDFError::NoFocusNodeError)- If no focus is currently set
Sourcefn get_focus_as_subject(&self) -> Result<Self::Subject, RDFError>
fn get_focus_as_subject(&self) -> Result<Self::Subject, RDFError>
Retrieves the current focus node as a subject, failing if not set or not a valid subject.
§Returns
Ok(subject)- The current focus as a subject nodeErr(RDFError::NoFocusNodeError)- If no focus is currently setErr(RDFError::ExpectedSubjectError)- If the focus is a literal or cannot be converted to a subject
Sourcefn get_path_for(
&mut self,
subject: &Self::Term,
predicate: &Self::IRI,
) -> Result<Option<SHACLPath>, RDFError>
fn get_path_for( &mut self, subject: &Self::Term, predicate: &Self::IRI, ) -> Result<Option<SHACLPath>, RDFError>
Parses and retrieves a SHACL path from a subject-predicate pair.
§Arguments
subject- The subject node to querypredicate- The predicate whose object should be parsed as a SHACL path
§Returns
Ok(Some(path))- If an object exists and was successfully parsed as a SHACL pathOk(None)- If no object exists or parsing failedErr(e)- If querying the graph for objects fails
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§
impl FocusRDF for InMemoryGraph
Implementation of the FocusRDF trait for managing a focus term.
The focus term is used to track a specific RDF term of interest during graph operations. This can be useful for navigation, querying, or maintaining context during traversals.