Skip to content

bindgen: offer a type-safe Rust API #3777

@djc

Description

@djc

Suggestion

This is the main API entry point in the windows-bindgen crate today:

pub fn bindgen<I, S>(args: I) -> Warningswhere
    I: IntoIterator<Item = S>,
    S: AsRef<str>;

You then have to pass what amounts to CLI arguments into this function. While I can understand that this is/has been expedient, it would be nice to offer an idiomatic type-safe Rust API instead. I think a builder-like API could work quite well and still allow substantial evolution without semver-incompatible bumps.

Something like:

windows_bindgen::builder()
    .output(Path::from("src/bindings.rs"))
    .modules(false)
    .style(Style::Sys)
    .comment(false)
    .generate()

Happy to help review such an API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions