Skip to content
This repository was archived by the owner on Jun 20, 2022. It is now read-only.
This repository was archived by the owner on Jun 20, 2022. It is now read-only.

Add Rust plugin APIs #325

Description

@mbrobbel

This proposal is work-in-progress.

To enable ergonomic development of plugins with Rust, we should add some feature-gated APIs with common methods and structures.

My proposal:

  • Add a plugin feature which is not part of the default features. Plugins can then depend on dqcsim like this:
[dependencies]
dqcsim = { version = "..", default-features = false, features = ["plugin"] }
  • Move the dqcsim::common::gates module behind the plugin feature-gate.
  • Add FrontEnd//Backend/Operator traits:
trait FrontEnd {
    fn run(&self)
    fn initialize(&self) -> { .. }
    fn host(&self) -> { .. }
}
  • Add a (procedural macro) to derive a PluginDefinition (PluginType and PluginMetadata) for a struct. Also allow deriving the plugin arguments (opts).
#[derive(FrontEnd)]
#[dqcsim(name="front-end", author = "me", version = "0.1.0")]
struct MyPlugin {
  //#[dqcsim(opt="input.file")]
  input: PathBuf,
}

#[derive(DqcsimOpt)]
struct MyPluginOpt {
}

impl TryFrom<Vec<ArbCmd>> for MyPluginOpt {}

impl MyPlugin {
  #[dqcsim(run)]
  fn run(&self, opt) {
      let opt: MyPluginOpt = opt.try_from()?;

  }
}

//
impl FrontEnd for MyPlugin {
  fn run(&self) -> {
    MyPlugin::run(self)
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions