Skip to main content

ShapeConstraint

Struct ShapeConstraint 

Source
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: String

The performative this shape constrains.

§rules: Vec<ShapeRule>

The rules that expanded messages must satisfy.

Implementations§

Source§

impl ShapeConstraint

Source

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.

Source

pub fn check_with_work( &self, sexpr: &SExpr, work: u64, ) -> Result<(), ShapeViolation>

Source

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).

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for ShapeConstraint

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ShapeConstraint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ShapeConstraint

Source§

impl PartialEq for ShapeConstraint

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ShapeConstraint

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.