datalog_structural_model/termination/
criterion.rs1use std::fmt;
4
5#[derive(
8 Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize,
9)]
10#[serde(transparent)]
11pub struct LawVersion(u32);
12
13impl LawVersion {
14 #[must_use]
16 pub const fn new(version: u32) -> Self {
17 Self(version)
18 }
19
20 #[must_use]
22 pub const fn get(self) -> u32 {
23 self.0
24 }
25}
26
27impl fmt::Display for LawVersion {
28 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29 write!(f, "v{}", self.0)
30 }
31}
32
33#[derive(
37 Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize,
38)]
39#[non_exhaustive]
40pub enum TerminationCriterion {
41 WeaklyAcyclic,
43}
44
45impl TerminationCriterion {
46 #[must_use]
48 pub const fn label(self) -> &'static str {
49 match self {
50 Self::WeaklyAcyclic => "weakly-acyclic",
51 }
52 }
53
54 #[must_use]
56 pub const fn law_version(self) -> LawVersion {
57 match self {
58 Self::WeaklyAcyclic => LawVersion::new(1),
59 }
60 }
61}
62
63impl fmt::Display for TerminationCriterion {
64 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
65 write!(f, "{} {}", self.label(), self.law_version())
66 }
67}