shacl_ir/components/class.rs
1use rudof_rdf::rdf_core::term::Object;
2use std::fmt::Display;
3
4/// The condition specified by sh:class is that each value node is a SHACL
5/// instance of a given type.
6///
7/// https://www.w3.org/TR/shacl/#ClassConstraintComponent
8#[derive(Debug, Clone)]
9pub struct Class {
10 class_rule: Object,
11}
12
13impl Class {
14 pub fn new(class_rule: Object) -> Self {
15 Class { class_rule }
16 }
17
18 pub fn class_rule(&self) -> &Object {
19 &self.class_rule
20 }
21}
22
23impl Display for Class {
24 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25 write!(f, "Class: {}", self.class_rule())
26 }
27}