Trait PatchVerification

Source
pub trait PatchVerification {
    type Error: Error;
    type Node: HugrNode;

    // Required method
    fn verify(
        &self,
        h: &impl HugrView<Node = Self::Node>,
    ) -> Result<(), Self::Error>;

    // Provided methods
    fn invalidation_set(&self) -> impl Iterator<Item = Self::Node> { ... }
    fn invalidated_nodes(
        &self,
        h: &impl HugrView<Node = Self::Node>,
    ) -> impl Iterator<Item = Self::Node> { ... }
}
Expand description

Verify that a patch application would succeed.

Required Associated Types§

Source

type Error: Error

The type of Error with which this Rewrite may fail

Source

type Node: HugrNode

The node type of the HugrView that this patch applies to.

Required Methods§

Source

fn verify( &self, h: &impl HugrView<Node = Self::Node>, ) -> Result<(), Self::Error>

Checks whether the rewrite would succeed on the specified Hugr. If this call succeeds, Patch::apply should also succeed on the same h If this calls fails, Patch::apply would fail with the same error.

Provided Methods§

Source

fn invalidation_set(&self) -> impl Iterator<Item = Self::Node>

👎Deprecated: Use/implement invalidated_nodes instead

The nodes invalidated by the rewrite. Deprecated: implement Self::invalidated_nodes instead. The default returns the empty iterator; this should be fine as there are no external calls.

Source

fn invalidated_nodes( &self, h: &impl HugrView<Node = Self::Node>, ) -> impl Iterator<Item = Self::Node>

Returns the nodes removed or altered by the rewrite. Modifying any of these nodes will invalidate the rewrite.

Two impl Rewrites can be composed if their invalidated_nodes are disjoint.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§