srdf/
shacl_path.rs
1use iri_s::IriS;
2use serde::Serialize;
3use std::fmt::Display;
4
5#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize)]
9pub enum SHACLPath {
10 Predicate { pred: IriS },
11 Alternative { paths: Vec<SHACLPath> },
12 Sequence { paths: Vec<SHACLPath> },
13 Inverse { path: Box<SHACLPath> },
14 ZeroOrMore { path: Box<SHACLPath> },
15 OneOrMore { path: Box<SHACLPath> },
16 ZeroOrOne { path: Box<SHACLPath> },
17}
18
19impl SHACLPath {
20 pub fn iri(pred: IriS) -> Self {
21 SHACLPath::Predicate { pred }
22 }
23
24 pub fn pred(&self) -> Option<&IriS> {
25 match self {
26 SHACLPath::Predicate { pred } => Some(pred),
27 _ => None,
28 }
29 }
30}
31
32impl Display for SHACLPath {
33 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
34 match self {
35 SHACLPath::Predicate { pred } => write!(f, "{pred}"),
36 SHACLPath::Alternative { .. } => todo!(),
37 SHACLPath::Sequence { .. } => todo!(),
38 SHACLPath::Inverse { .. } => todo!(),
39 SHACLPath::ZeroOrMore { .. } => todo!(),
40 SHACLPath::OneOrMore { .. } => todo!(),
41 SHACLPath::ZeroOrOne { .. } => todo!(),
42 }
43 }
44}
45
46