Skip to main content

shacl_ast/
lib.rs

1//! SHACL Abstract Syntax
2//!
3//! Ths abstract syntax follows the [SHACL spec](https://www.w3.org/TR/shacl/)
4//!
5
6#![deny(rust_2018_idioms)]
7pub mod ast;
8pub use ast::*;
9
10/// SHACL Formats supported. Mostly RDF formats
11/// In the future, we could also support SHACL Compact format
12#[derive(Debug, Clone, Default)]
13pub enum ShaclFormat {
14    Internal,
15    #[default]
16    Turtle,
17    NTriples,
18    RdfXml,
19    TriG,
20    N3,
21    NQuads,
22    JsonLd,
23}
24
25impl ShaclFormat {
26    /// Returns the MIME type for the SHACL format
27    pub fn mime_type(&self) -> &str {
28        match self {
29            ShaclFormat::Internal => "application/shacl+json",
30            ShaclFormat::Turtle => "text/turtle",
31            ShaclFormat::NTriples => "application/n-triples",
32            ShaclFormat::RdfXml => "application/rdf+xml",
33            ShaclFormat::TriG => "application/trig",
34            ShaclFormat::N3 => "text/n3",
35            ShaclFormat::NQuads => "application/n-quads",
36            ShaclFormat::JsonLd => "application/ld+json",
37        }
38    }
39}