[][src]Struct dqcsim::plugin::definition::PluginDefinition

pub struct PluginDefinition {
    pub initialize: Box<dyn Fn(&mut PluginState, Vec<ArbCmd>) -> Result<()> + Send + 'static>,
    pub drop: Box<dyn Fn(&mut PluginState) -> Result<()> + Send + 'static>,
    pub run: Box<dyn Fn(&mut PluginState, ArbData) -> Result<ArbData> + Send + 'static>,
    pub allocate: Box<dyn Fn(&mut PluginState, Vec<QubitRef>, Vec<ArbCmd>) -> Result<()> + Send + 'static>,
    pub free: Box<dyn Fn(&mut PluginState, Vec<QubitRef>) -> Result<()> + Send + 'static>,
    pub gate: Box<dyn Fn(&mut PluginState, Gate) -> Result<Vec<QubitMeasurementResult>> + Send + 'static>,
    pub modify_measurement: Box<dyn Fn(&mut PluginState, QubitMeasurementResult) -> Result<Vec<QubitMeasurementResult>> + Send + 'static>,
    pub advance: Box<dyn Fn(&mut PluginState, u64) -> Result<()> + Send + 'static>,
    pub upstream_arb: Box<dyn Fn(&mut PluginState, ArbCmd) -> Result<ArbData> + Send + 'static>,
    pub host_arb: Box<dyn Fn(&mut PluginState, ArbCmd) -> Result<ArbData> + Send + 'static>,
    // some fields omitted
}

Defines a plugin.

This struct is constructed by the user (or the foreign language API). The behavior of the plugin is defined by a number of closures that the user must provide. For more information about the callback functions, refer to the documentation of the foreign language API setter functions.

Fields

initialize: Box<dyn Fn(&mut PluginState, Vec<ArbCmd>) -> Result<()> + Send + 'static>

Initialization callback.

drop: Box<dyn Fn(&mut PluginState) -> Result<()> + Send + 'static>

Finalization callback.

run: Box<dyn Fn(&mut PluginState, ArbData) -> Result<ArbData> + Send + 'static>

Run callback for frontends.

allocate: Box<dyn Fn(&mut PluginState, Vec<QubitRef>, Vec<ArbCmd>) -> Result<()> + Send + 'static>

Qubit allocation callback for operators and backends.

free: Box<dyn Fn(&mut PluginState, Vec<QubitRef>) -> Result<()> + Send + 'static>

Qubit deallocation callback for operators and backends.

gate: Box<dyn Fn(&mut PluginState, Gate) -> Result<Vec<QubitMeasurementResult>> + Send + 'static>

Gate execution callback for operators and backends.

modify_measurement: Box<dyn Fn(&mut PluginState, QubitMeasurementResult) -> Result<Vec<QubitMeasurementResult>> + Send + 'static>

Measurement modification callback for operators.

advance: Box<dyn Fn(&mut PluginState, u64) -> Result<()> + Send + 'static>

Callback for advancing time for operators and backends.

upstream_arb: Box<dyn Fn(&mut PluginState, ArbCmd) -> Result<ArbData> + Send + 'static>

Callback function for handling an arb from upstream for operators and backends.

host_arb: Box<dyn Fn(&mut PluginState, ArbCmd) -> Result<ArbData> + Send + 'static>

Callback function for handling an arb from the host.

Methods

impl PluginDefinition[src]

pub fn new(
    typ: PluginType,
    metadata: impl Into<PluginMetadata>
) -> PluginDefinition
[src]

Constructs a new plugin definition with default callbacks.

The callbacks can be overridden by modifying the boxed callback fields directly.

pub fn get_type(&self) -> PluginType[src]

Returns the plugin type.

pub fn set_type(&mut self, typ: PluginType)[src]

Sets the type of the plugin.

pub fn get_metadata(&self) -> &PluginMetadata[src]

Returns the plugin metadata.

Trait Implementations

impl Debug for PluginDefinition[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,