hugr_core::extension::simple_op

Trait 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,
        extension: Weak<Extension>,
    ) -> 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, extension: Weak<Extension>, ) -> 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§