shex_ast/ir/
node_constraint.rs

1use crate::{ast::NodeConstraint as AstNodeConstraint, Cond};
2use std::fmt::Display;
3
4/// Represents compiled node constraints
5#[derive(Debug, PartialEq, Clone)]
6pub struct NodeConstraint {
7    source: AstNodeConstraint,
8    cond: Cond,
9    display: String,
10}
11
12impl NodeConstraint {
13    pub fn new(nc: AstNodeConstraint, cond: Cond, display: String) -> Self {
14        NodeConstraint {
15            source: nc,
16            cond,
17            display,
18        }
19    }
20
21    pub fn cond(&self) -> Cond {
22        self.cond.clone()
23    }
24}
25
26impl Display for NodeConstraint {
27    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
28        write!(f, "{}", self.display)
29    }
30}