pub struct GraphValidation { /* private fields */ }
Expand description
The In-Memory Graph Validation algorithm.
use std::path::Path;
use shacl_validation::shacl_processor::GraphValidation;
use shacl_validation::shacl_processor::ShaclValidationMode;
use shacl_validation::shacl_processor::ShaclProcessor;
use shacl_validation::store::ShaclDataManager;
use srdf::RDFFormat;
let graph_validation = GraphValidation::new(
Path::new("../examples/book_conformant.ttl"), // example graph (refer to the examples folder)
RDFFormat::Turtle, // serialization format of the graph
None, // no base is defined
ShaclValidationMode::Native, // use the Native mode (performance)
)
.unwrap();
// the following schema should generate no errors when the conforming graph
// loaded in the previous declaration is used for validation
let schema = std::fs::read_to_string(Path::new("../examples/book.ttl")).unwrap();
let cursor = std::io::Cursor::new(schema);
let compiled_schema = ShaclDataManager::load(cursor, RDFFormat::Turtle, None).unwrap();
let report = graph_validation.validate(&compiled_schema).unwrap();
assert_eq!(report.results().len(), 0);
Implementations§
Source§impl GraphValidation
impl GraphValidation
Sourcepub fn from_path(
data: &Path,
data_format: RDFFormat,
base: Option<&str>,
mode: ShaclValidationMode,
) -> Result<Self, ValidateError>
pub fn from_path( data: &Path, data_format: RDFFormat, base: Option<&str>, mode: ShaclValidationMode, ) -> Result<Self, ValidateError>
Returns an In-Memory Graph validation SHACL processor.
§Arguments
data
- A path to the graph’s serialization filedata_format
- Any of the possible RDF serialization formatsbase
- An optional String, the base URImode
- Any of the possible SHACL validation modes
§Examples
use std::path::Path;
use shacl_validation::shacl_processor::GraphValidation;
use shacl_validation::shacl_processor::ShaclValidationMode;
use shacl_validation::shacl_processor::ShaclProcessor;
use srdf::RDFFormat;
let graph_validation = GraphValidation::new(
Path::new("../examples/book_conformant.ttl"), // example graph (refer to the examples folder)
RDFFormat::Turtle, // serialization format of the graph
None, // no base is defined
ShaclValidationMode::Native, // use the Native mode (performance)
);
pub fn from_graph(graph: Graph, mode: ShaclValidationMode) -> GraphValidation
Trait Implementations§
Source§impl ShaclProcessor<RdfData> for GraphValidation
impl ShaclProcessor<RdfData> for GraphValidation
fn store(&self) -> &RdfData
fn runner(&self) -> &dyn Engine<RdfData>
Source§fn validate(
&self,
shapes_graph: &CompiledSchema<S>,
) -> Result<ValidationReport, ValidateError>
fn validate( &self, shapes_graph: &CompiledSchema<S>, ) -> Result<ValidationReport, ValidateError>
Executes the Validation of the provided Graph, in any of the supported
formats, against the shapes graph passed as an argument. As a result,
the Validation Report generated from the validation process is returned. Read more
Auto Trait Implementations§
impl Freeze for GraphValidation
impl !RefUnwindSafe for GraphValidation
impl Send for GraphValidation
impl Sync for GraphValidation
impl Unpin for GraphValidation
impl !UnwindSafe for GraphValidation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more