pub fn bindgen<I, S>(args: I)Expand description
Generates bindings using command-line-style arguments.
let args = [
"--out",
"src/bindings.rs",
"--filter",
"GetTickCount",
];
windows_bindgen::bindgen(args);Supported arguments:
--in: Metadata files or directories.--out: Generated Rust file.--filter: Included or excluded APIs.--rustfmt: Comma-separatedrustfmt --configoptions, such asmax_width=120.--derive: Extra derives asType=Trait,OtherTrait, for exampleSYSTEMTIME=Debug.--modules: Nests items in one module per namespace.--package: Generates a package with one file per namespace.--sys: Generates raw bindings that depend only onwindows-link.--extern: Uses extern declarations in any style; the caller supplies import libraries.--full: Adds class wrappers, inherited forwarders, handle wrappers, and implementation traits for interfaces not markedExclusiveTo.--implement: Implementation traits for dotted interface names or namespace prefixes. Without names, includes every native and WinRT interface in scope. SeeBindgen::implementfor restrictions on member filters with named selectors.--compose: Selects WinRT class composition targets.--dead-code: Emitspub(crate)items for dead-code analysis.--etc: Reads arguments from command files.--filter-file: Reads filters from text files.
§--out
Defaults to bindings.rs in the runtime OUT_DIR directory. An explicit path is required when
OUT_DIR is unset or empty, and always with --package. Bindgen does not emit Cargo
dependency-tracking directives.
§--filter
Uses the same syntax as Bindgen::filter, including groups and exclusions:
--filter GetTickCount HWND
--filter Windows.Win32.GetTickCount
--filter Windows::Win32::{GetTickCount, GetTickCount64}
--filter Windows.FoundationSee Bindgen::filter for name resolution, member selection, dependencies, and rule precedence.
§--filter-file and --etc
Use a filter file for longer filter lists:
--filter-file path/to/filter.txtFilter and command files separate arguments with whitespace. Filter expressions keep {...}
groups together across lines and allow trailing commas:
ID2D1RenderTarget::{
BeginDraw,
EndDraw,
Clear, // Reset the surface
}Lines beginning with // after optional whitespace are comments. Inline comments start with
a separate // token, followed by whitespace or the end of the line. This leaves UNC paths
such as --in //server/share/input.winmd intact. In command files, grouping applies only to
--filter arguments; braces in paths are literal.
The in-repo crates use this convention; see the filter .txt files in
crates/tools/bindings/src.