Skip to main content

shacl_ir/components/
node.rs

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