toasty_core/schema/app/
constraint.rs

1mod length;
2pub use length::ConstraintLength;
3
4use crate::{stmt, Result};
5
6#[derive(Debug, Clone)]
7pub enum Constraint {
8    Length(ConstraintLength),
9}
10
11impl Constraint {
12    pub fn length_less_than(max: u64) -> Self {
13        ConstraintLength {
14            min: None,
15            max: Some(max),
16        }
17        .into()
18    }
19
20    pub fn check(&self, expr: &stmt::Entry<'_>) -> Result<()> {
21        match self {
22            Constraint::Length(length) => length.check(expr),
23        }
24    }
25}