Rust
rudof is a set of Rust crates. Most programs need only rudof_lib. It gives one entry point, the Rudof struct, to all the features of the command line tool.
Installation
cargo add rudof_lib
RDF data, ShEx, SHACL and SPARQL are always available. The other subsystems are Cargo features, so that you can make smaller builds, for example for WebAssembly. The rudof_lib README lists the features.
How the API works
Each operation starts with a method call on a Rudof instance. The method returns a builder for the operation. You chain options on the builder, and then call .execute().
#![allow(unused)]
fn main() {
use rudof_lib::{Rudof, RudofConfig};
use rudof_lib::formats::{InputSpec, ShExFormat, ResultShExValidationFormat};
use std::str::FromStr;
let mut rudof = Rudof::new(RudofConfig::default());
let data = vec![InputSpec::from_str(r#"
prefix : <http://example.org/>
:alice :name "Alice" .
"#)?];
rudof.load_data().with_data(&data).execute()?;
let schema = InputSpec::from_str(r#"
prefix : <http://example.org/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
:Person { :name xsd:string }
"#)?;
rudof.load_shex_schema(&schema).with_shex_schema_format(&ShExFormat::ShExC).execute()?;
let shapemap = InputSpec::from_str("<http://example.org/alice>@<http://example.org/Person>")?;
rudof.load_shapemap(&shapemap).execute()?;
rudof.validate_shex().execute()?;
rudof.serialize_shex_validation_results(&mut std::io::stdout())
.with_result_shex_validation_format(&ResultShExValidationFormat::Compact)
.execute()?;
}
An InputSpec is inline content, a file path or a URL.
Topics
| Page | Content |
|---|---|
| Core and session state | Create a Rudof instance, change the configuration, reset the state. |
| Data | Load, inspect, change, stage and compare RDF data. Endpoints and service descriptions. |
| ShEx | Validate with ShEx. ShExPath, precompiled schemas and external shapes. |
| SHACL | Validate with SHACL. |
| Property graphs | PG-Schema validation and the embedded property graph database. |
| SPARQL queries | Run SPARQL queries. |
| Conversion and comparison | Convert and compare schemas. DCTAP and rdf-config. |
| Data generation and materialization | Generate synthetic data, and build RDF from Map semantic actions. |
| Low-level RDF | The rudof_rdf traits, backends and parser combinators. |
Crates
All crates are on crates.io, and their API reference is on docs.rs. The README of each crate, which crates.io shows, describes its purpose and internals.
| Crate | Purpose |
|---|---|
rudof_lib | The main library. Use it first. |
rudof_rdf | RDF model, parsers, serializers, SPARQL endpoints and backends. |
rudof_rdf_sink | Destinations for the RDF triples that rudof produces. |
rudof_iri | IRI types. |
prefixmap | Prefix maps. |
shex_ast | ShEx abstract syntax, parsers and ShapeMaps. |
shex_validation | ShEx validation. |
shape_path | ShExPath. |
rbe | Regular bag expressions. |
shacl | SHACL validation. |
dctap | DCTAP profiles. |
pgschema | PG-Schema and property graph validation. |
rdf_config | rdf-config documents. |
mie | MIE documents. |
shapes_converter | Conversion between shape languages. |
shapes_comparator | Comparison of shapes. |
sparql_service | SPARQL service descriptions and the query processor. |
rudof_generate | Synthetic data generation. |
rudof_mcp | The MCP server. |
rudof_config | The TOML configuration layer. |
rudof_viz | Visualization primitives. |
rudof_typing | The typing cache of the validators. |
rudof_earl | EARL reports. |
Since version 0.2.17, all rudof crates have the same version number. If you use several rudof crates, use the same version for all of them.