Skip to main content

shacl_ir/components/
not.rs

1use crate::shape_label_idx::ShapeLabelIdx;
2use std::fmt::Display;
3
4/// sh:not specifies the condition that each value node cannot conform to a
5/// given shape. This is comparable to negation and the logical "not" operator.
6///
7/// https://www.w3.org/TR/shacl/#NotConstraintComponent
8#[derive(Debug, Clone)]
9pub struct Not {
10    shape: ShapeLabelIdx,
11}
12
13impl Not {
14    pub fn new(shape: ShapeLabelIdx) -> Self {
15        Not { shape }
16    }
17
18    pub fn shape(&self) -> &ShapeLabelIdx {
19        &self.shape
20    }
21}
22
23impl Display for Not {
24    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25        write!(f, "Not [{}]", self.shape)
26    }
27}