Trait MakeExtensionOp

Source
pub trait MakeExtensionOp {
    // Required methods
    fn op_id(&self) -> OpName;
    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 op_id(&self) -> OpName

The OpDef::name of ExtensionOps from which Self can be loaded.

This identifer must be unique within the extension with which the OpDef is registered. An ExtensionOp instantiating this OpDef will report self.opdef_id() as its ExtensionOp::unqualified_id.

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§