shapes_converter/shacl_to_shex/
shacl2shex_config.rs

1use serde::{Deserialize, Serialize};
2use shacl_validation::shacl_config::ShaclConfig;
3
4/// Defines the configuration of the converter
5#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Default)]
6pub struct Shacl2ShExConfig {
7    /// Starting shapes mode. Default: NonBNodes
8    pub starting_shapes_mode: Option<StartShapeMode>,
9
10    /// If true, embed blank nodes in the ShEx schema
11    pub embed_bnodes: Option<bool>,
12
13    /// SHACL configuration
14    pub shacl: Option<ShaclConfig>,
15
16    /// Add an `rdf:type` constraint for `sh:targetClass` declarations
17    pub add_target_class: Option<bool>,
18}
19
20impl Shacl2ShExConfig {
21    pub fn starting_shapes_mode(&self) -> StartShapeMode {
22        match &self.starting_shapes_mode {
23            None => StartShapeMode::default(),
24            Some(sm) => sm.clone(),
25        }
26    }
27
28    pub fn add_target_class(&self) -> bool {
29        match &self.add_target_class {
30            None => true,
31            Some(atc) => *atc,
32        }
33    }
34}
35
36#[derive(Serialize, Deserialize, PartialEq, Debug, Clone, Default)]
37pub enum StartShapeMode {
38    /// Process shapes which are not blank nodes
39    #[default]
40    NonBNodes,
41}