[][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.

Implementations

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

impl !RefUnwindSafe for PluginDefinition

impl Send for PluginDefinition

impl !Sync for PluginDefinition

impl Unpin for PluginDefinition

impl !UnwindSafe for PluginDefinition

Blanket Implementations

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

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

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

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<V, T> VZip<V> for T where
    V: MultiLane<T>,