pub trait OpTrait: Sized + Clone {
// Required methods
fn description(&self) -> &str;
fn tag(&self) -> OpTag;
// Provided methods
fn try_node_handle<N, H>(&self, node: N) -> Option<H>
where N: HugrNode,
H: NodeHandle<N> + From<N> { ... }
fn dataflow_signature(&self) -> Option<Cow<'_, Signature>> { ... }
fn other_input(&self) -> Option<EdgeKind> { ... }
fn other_output(&self) -> Option<EdgeKind> { ... }
fn static_input(&self) -> Option<EdgeKind> { ... }
fn static_output(&self) -> Option<EdgeKind> { ... }
fn non_df_port_count(&self, dir: Direction) -> usize { ... }
fn substitute(&self, _subst: &Substitution<'_>) -> Self { ... }
}
Expand description
Trait implemented by all OpType
variants.
Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
A human-readable description of the operation.
Provided Methods§
Sourcefn try_node_handle<N, H>(&self, node: N) -> Option<H>
fn try_node_handle<N, H>(&self, node: N) -> Option<H>
Tries to create a specific NodeHandle
for a node with this operation
type.
Fails if the operation’s OpTrait::tag
does not match the
NodeHandle::TAG
of the requested handle.
Sourcefn dataflow_signature(&self) -> Option<Cow<'_, Signature>>
fn dataflow_signature(&self) -> Option<Cow<'_, Signature>>
The signature of the operation.
Only dataflow operations have a signature, otherwise returns None.
Sourcefn other_input(&self) -> Option<EdgeKind>
fn other_input(&self) -> Option<EdgeKind>
The edge kind for the non-dataflow inputs of the operation, not described by the signature.
If not None, a single extra input port of that kind will be present.
Sourcefn other_output(&self) -> Option<EdgeKind>
fn other_output(&self) -> Option<EdgeKind>
The edge kind for the non-dataflow outputs of the operation, not described by the signature.
If not None, a single extra output port of that kind will be present.
Sourcefn static_input(&self) -> Option<EdgeKind>
fn static_input(&self) -> Option<EdgeKind>
The edge kind for a single constant input of the operation, not described by the dataflow signature.
If not None, an extra input port of that kind will be present after the
dataflow input ports and before any OpTrait::other_input
ports.
Sourcefn static_output(&self) -> Option<EdgeKind>
fn static_output(&self) -> Option<EdgeKind>
The edge kind for a single constant output of the operation, not described by the dataflow signature.
If not None, an extra output port of that kind will be present after the
dataflow input ports and before any OpTrait::other_output
ports.
Sourcefn non_df_port_count(&self, dir: Direction) -> usize
fn non_df_port_count(&self, dir: Direction) -> usize
Get the number of non-dataflow multiports.
Sourcefn substitute(&self, _subst: &Substitution<'_>) -> Self
fn substitute(&self, _subst: &Substitution<'_>) -> Self
Apply a type-level substitution to this OpType
, i.e. replace
type variables with new types.
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.