Skip to content

--generate-stub for Rust #1347

Open

Description

@EugenDueck

Does anything speak against adding a --generate-stub flag for Rust, like the one for CSharp?

> wit-bindgen csharp --help | grep stub
      --generate-stub
          Whether or not to generate a stub class for exported functions

If not, I may consider contributing a PR for this.

Activity

  1. alexcrichton commented on Aug 12, 2025

    @alexcrichton
    Member

    Does the --stubs flag work for you?

  2. EugenDueck commented on Aug 12, 2025

    @EugenDueck
    Author

    The problem with --stubs is that the stub gets embedded within the bindings file. What I'm looking for is something like a separate lib.rs file containing just the stub. A file that can be manually edited, and that won't get overwritten when re-running wit-bindgen (unless perhaps the --generate-stub flag is set again)

  3. EugenDueck commented on Aug 12, 2025

    @EugenDueck
    Author

    However, as the rust command already has the --stubs flag, adding another --generate-stubs doesn't feel ideal. Perhaps adding an optional value to --stubs that can be either embedded or separate, defaulting to the former if we want to maintain backwards compatibility?

  4. EugenDueck commented on Aug 13, 2025

    @EugenDueck
    Author

    The reason I wanted this no longer applies, as I already have a WIT generator and decided to just add a flag to also generate the stubs.
    However, if there’s interest in such a feature for wit-bindgen, I may take a stab at it.

  5. alexcrichton commented on Aug 13, 2025

    @alexcrichton
    Member

    Ah ok makes sense, and yeah I think it'd be reasonable to add support for this and generating into a separate file

  6. EugenDueck commented on Aug 15, 2025

    @EugenDueck
    Author

    I've created a draft PR with a couple of discussion points: #1354

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions