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

Add Rust plugin APIs #325

Open
mbrobbel opened this issue Dec 6, 2019 · 0 comments
Open

Add Rust plugin APIs #325

mbrobbel opened this issue Dec 6, 2019 · 0 comments
Labels
enhancement New feature or request lang:rust 🦀 Involves the Rust crate

Comments

@mbrobbel
Copy link
Collaborator

mbrobbel commented Dec 6, 2019

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)
  }
}
@mbrobbel mbrobbel added enhancement New feature or request lang:rust 🦀 Involves the Rust crate labels Dec 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request lang:rust 🦀 Involves the Rust crate
Projects
None yet
Development

No branches or pull requests

1 participant