1use srdf::SRDFBuilder;
2use std::fmt::Display;
3
4use crate::{node_shape::NodeShape, property_shape::PropertyShape};
5
6#[derive(Debug, Clone)]
7pub enum Shape {
8 NodeShape(Box<NodeShape>),
9 PropertyShape(PropertyShape),
10}
11
12impl Shape {
13 pub fn write<RDF>(&self, rdf: &mut RDF) -> Result<(), RDF::Err>
14 where
15 RDF: SRDFBuilder,
16 {
17 match self {
18 Shape::NodeShape(ns) => {
19 ns.write(rdf)?;
20 }
21 Shape::PropertyShape(ps) => {
22 ps.write(rdf)?;
23 }
24 }
25 Ok(())
26 }
27}
28
29impl Display for Shape {
30 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
31 match &self {
32 Shape::NodeShape(ns) => write!(f, "{ns}"),
33 Shape::PropertyShape(ps) => write!(f, "{ps}"),
34 }
35 }
36}