Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment: Use Rust code directly as the interface definition. #416

Closed
wants to merge 1 commit into from

Commits on Aug 9, 2021

  1. Experiment: Use Rust code directly as the interface definition.

    This is a fun little something I've been messing around with,
    partly just to learn more about Rust macros and `syn`, and partly
    to see if they could make a good replacement for our current use
    of WebIDL for an interface definition language.
    
    Key ideas:
    
    * Declare the UniFFI component interface using a restricted subset
      of Rust syntax, directly as part of the code that implements the
      Rust side of the component. There is no separate .udl file.
    
    * Use a procedural macro to insert the Rust scaffolding directly
      at crate build time, rather than requiring a separate `build.rs`
      setup to generate and include it.
    
    * When generating the foreign-language bindings, have `uniffi-bindgen`
      parse the Rust source directly in order to find the component
      interface.
    
    This seems to work surprisingly well so far. If we do decide to
    go this route, the code here will need a lot more polish before
    it's ready to land...but it works! And it works in a way that's
    not too conceptually different from what we're currently doing
    with a separate `.udl` file.
    rfk committed Aug 9, 2021
    Configuration menu
    Copy the full SHA
    a7bd4f9 View commit details
    Browse the repository at this point in the history