Trait hugr_core::extension::simple_op::MakeExtensionOp

source ·
pub trait MakeExtensionOp: NamedOp {
    // Required methods
    fn from_extension_op(ext_op: &ExtensionOp) -> Result<Self, OpLoadError>
       where Self: Sized;
    fn type_args(&self) -> Vec<TypeArg>;

    // Provided methods
    fn from_optype(op: &OpType) -> Option<Self>
       where Self: Sized { ... }
    fn to_registered(
        self,
        extension_id: ExtensionId,
        registry: &ExtensionRegistry
    ) -> RegisteredOp<'_, Self>
       where Self: Sized { ... }
}
Expand description

Traits implemented by types which can be loaded from ExtensionOps, i.e. concrete instances of OpDefs, with defined type arguments.

Required Methods§

source

fn from_extension_op(ext_op: &ExtensionOp) -> Result<Self, OpLoadError>
where Self: Sized,

Try to load one of the operations of this set from an OpDef.

source

fn type_args(&self) -> Vec<TypeArg>

Any type args which define this operation.

Provided Methods§

source

fn from_optype(op: &OpType) -> Option<Self>
where Self: Sized,

Try to instantiate a variant from an OpType. Default behaviour assumes an ExtensionOp and loads from the name.

source

fn to_registered( self, extension_id: ExtensionId, registry: &ExtensionRegistry ) -> RegisteredOp<'_, Self>
where Self: Sized,

Given the ID of the extension this operation is defined in, and a registry containing that extension, return a RegisteredOp.

Implementors§

source§

impl MakeExtensionOp for ConvertOpType

source§

impl MakeExtensionOp for ConcreteIntOp

source§

impl MakeExtensionOp for ListOpInst

source§

impl MakeExtensionOp for ConcreteLogicOp

source§

impl<T: MakeOpDef> MakeExtensionOp for T

Blanket implementation for non-polymorphic operations - OpDefs with no type parameters.