Skip to main content

shacl_ir/components/
datatype.rs

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