windows-rs icon indicating copy to clipboard operation
windows-rs copied to clipboard

bindgen: offer a type-safe Rust API

Open djc opened this issue 3 months ago • 1 comments

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.

djc avatar Sep 26 '25 12:09 djc

Good idea - originally this was a command line tool but a library was more convenient for most scenarios.

kennykerr avatar Oct 02 '25 20:10 kennykerr