pub struct ShapeConstraint {
pub performative: String,
pub rules: Vec<ShapeRule>,
}Expand description
A shape constraint for a performative (REQ-220).
Declares the required structure of expanded messages for a specific performative. Multiple shape constraints on the same performative compose via conjunction (REQ-224).
Fields§
§performative: StringThe performative this shape constrains.
rules: Vec<ShapeRule>The rules that expanded messages must satisfy.
Implementations§
Source§impl ShapeConstraint
impl ShapeConstraint
Sourcepub fn check(&self, sexpr: &SExpr) -> Result<(), ShapeViolation>
pub fn check(&self, sexpr: &SExpr) -> Result<(), ShapeViolation>
Check an expanded S-expression against this shape constraint (REQ-223).
The sexpr should be the fully expanded message (after template expansion).
Returns Ok(()) if all rules are satisfied, or Err with the first violation.
pub fn check_with_work( &self, sexpr: &SExpr, work: u64, ) -> Result<(), ShapeViolation>
Sourcepub fn no_duplicate_keywords(&self) -> Result<(), String>
pub fn no_duplicate_keywords(&self) -> Result<(), String>
Check whether this constraint has any duplicate require/optional keywords at the same depth (REQ-222 §5).
Sourcepub fn max_depth(&self) -> Option<u32>
pub fn max_depth(&self) -> Option<u32>
Return the first declared max-depth bound, if any.
Prefer max_depths when validating every declared
bound (e.g. the R5 install-time check); this accessor is retained for
callers that only want a single representative bound.
Sourcepub fn max_depths(&self) -> impl Iterator<Item = u32>
pub fn max_depths(&self) -> impl Iterator<Item = u32>
Iterate over every (max-depth …) bound declared on this shape,
including bounds nested inside require/optional rules.
A shape may declare more than one MaxDepth rule, and the parser
allows (max-depth N) to appear among a parent rule’s children
(e.g. (require :payload list (max-depth N))). Install-time R5
(REQ-222 §4) must check every declared bound against the dialect’s
R2 limit — a top-level-only walk would silently accept oversized
nested bounds, since at runtime any subtree’s depth is bounded by
the whole message’s depth, so N > R2 is unreachable but still a
malformed declaration.