# SHAPES-rs
[![Shapes-rs](https://github.com/weso/shapes-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/weso/shapes-rs/actions/workflows/ci.yml)
[![dependency status](https://deps.rs/repo/github/weso/shapes-rs/status.svg)](https://deps.rs/repo/github/weso/shapes-rs)
This repo contains an RDF data shapes library implemented in Rust.
The implementation supports [ShEx](http://shex.io/), [SHACL](https://www.w3.org/TR/shacl/), [DCTap](https://www.dublincore.org/specifications/dctap/) and conversions between different RDF data modeling formalisms.
The code can be used as a Rust library but it also contains a binary called `rudof` which can be used as an RDF playground.
We provide binaries for Linux, Windows, Mac and Docker (see [releases](https://github.com/weso/shapes-rs/releases)), as well as Python bindings.
- [List of issues](https://github.com/weso/shapes-rs)
- [Discussion](https://github.com/weso/shapes-rs/discussions/landing)
- [FAQ](https://github.com/weso/shapes-rs/wiki/FAQ)
- [How to guides](https://github.com/weso/shapes-rs/wiki/Howto-guides)
- [Roadmap](https://github.com/weso/shapes-rs/issues/1)
## Installation
### Official releases
You can download a binary from the [latest release](https://github.com/weso/shapes-rs/releases/latest) page. There you will also find the compiled packages for the installation on your system using a package manager.
#### Ubuntu
Download the binary from [https://github.com/weso/shapes-rs/releases] and install the `.deb` package running the following commands after replacing X.X.X by the latest version:
```sh
wget https://github.com/weso/shapes-rs/releases/download/X.X.X/rudof_vX.X.X_amd64.deb
sudo dpkg -i rudof_vX.X.X_amd64.deb
```
#### Windows
The binary can be downloaded from [https://github.com/weso/shapes-rs/releases]
#### Mac
The binary is available at: [https://github.com/weso/shapes-rs/releases]
Compiling from source
### Compiling from source
`shapes-rs` has been implemented in Rust and is compiled using [cargo](https://doc.rust-lang.org/cargo/). The command `cargo run` can be used to compile and run locally the code.
For example:
```sh
cargo run -- validate --data examples/user.ttl --schema examples/user.shex --shapemap examples/user.sm
```
### Compiling from source and installing the binary (Debian)
Install `cargo deb` (only the first time)
```sh
cargo install cargo-deb
```
Create the `.deb` package by:
```sh
cargo deb
```
And run:
```sh
sudo dpkg -i target/debian/shapes-rs_0.0.11-1_amd64.deb
```
## Docker
The library is also published as a Docker image.
## Usage
### Some examples
The folder `examples` contains several example files with ShEx schemas and RDF data.
### Validate a simple RDF file with a ShEx schema using a ShapeMap
```sh
rudof validate --data examples/user.ttl --schema examples/user.shex --shapemap examples/user.sm
```
We maintain a Wiki page with some common [Usage scenarios and How-to guides](https://github.com/weso/shapes-rs/wiki/Howto-guides).
### Debugging information
It is possible to change the debug level information with:
```sh
export RUST_LOG=value
```
where `value` can be `debug` to show more verbose information or `info` to show basic information.
## Command line usage
```sh
RDF Data shapes implementation in Rust
Usage: rudof [OPTIONS] [COMMAND]
Commands:
shapemap Information about ShEx shapemaps
shex Information about ShEx schemas
validate RDF Validation using ShEx or SHACL
shex-validate RDF Validation using ShEx schemas
shacl-validate RDF Validation using SHACL shapes
data Information about RDF data
node Information about RDF nodes which are part of RDF Graphs
shacl Information about SHACL shapes
dctap Information and processing of DCTAP files
convert Conversion between different Data modeling technologies
help Print this message or the help of the given subcommand(s)
Options:
-d, --debug...
-h, --help Print help (see more with '--help')
-V, --version Print version
```
### Obtaining information about a ShEx schema
```sh
$ rudof shex --help
Information about ShEx schemas
Usage: rudof shex [OPTIONS] --schema
Options:
-s, --schema
-f, --format
[default: shexc] [possible values: internal, shexc, shexj, turtle, ntriples, rdfxml, trig, n3, nquads]
-r, --result-format
[default: shexj] [possible values: internal, shexc, shexj, turtle, ntriples, rdfxml, trig, n3, nquads]
-t, --show elapsed time
--statistics
-o, --output-file