pub struct Config {Show 37 fields
pub header: Option<String>,
pub includes: Vec<String>,
pub sys_includes: Vec<String>,
pub after_includes: Option<String>,
pub trailer: Option<String>,
pub include_guard: Option<String>,
pub pragma_once: bool,
pub no_includes: bool,
pub autogen_warning: Option<String>,
pub include_version: bool,
pub namespace: Option<String>,
pub namespaces: Option<Vec<String>>,
pub using_namespaces: Option<Vec<String>>,
pub braces: Braces,
pub line_length: usize,
pub tab_width: usize,
pub line_endings: LineEndingStyle,
pub language: Language,
pub cpp_compat: bool,
pub style: Style,
pub sort_by: SortKey,
pub usize_is_size_t: bool,
pub parse: ParseConfig,
pub export: ExportConfig,
pub macro_expansion: MacroExpansionConfig,
pub layout: LayoutConfig,
pub function: FunctionConfig,
pub structure: StructConfig,
pub enumeration: EnumConfig,
pub constant: ConstantConfig,
pub defines: HashMap<String, String>,
pub documentation: bool,
pub documentation_style: DocumentationStyle,
pub documentation_length: DocumentationLength,
pub pointer: PtrConfig,
pub only_target_dependencies: bool,
pub cython: CythonConfig,
/* private fields */
}Expand description
A collection of settings to customize the generated bindings.
Fields§
§header: Option<String>Optional text to output at the beginning of the file
includes: Vec<String>A list of additional includes to put at the beginning of the generated header
sys_includes: Vec<String>A list of additional system includes to put at the beginning of the generated header
after_includes: Option<String>Optional verbatim code added after the include blocks
trailer: Option<String>Optional text to output at the end of the file
include_guard: Option<String>Optional name to use for an include guard
pragma_once: boolAdd a #pragma once guard
no_includes: boolGenerates no includes at all. Overrides all other include options
This option is useful when using cbindgen with tools such as python’s cffi which doesn’t understand include directives
autogen_warning: Option<String>Optional text to output at major sections to deter manual editing
include_version: boolInclude a comment with the version of cbindgen used to generate the file
namespace: Option<String>An optional name for the root namespace. Only applicable when language=“C++”
namespaces: Option<Vec<String>>An optional list of namespaces. Only applicable when language=“C++”
using_namespaces: Option<Vec<String>>An optional list of namespaces to declare as using. Only applicable when language=“C++”
braces: BracesThe style to use for braces
line_length: usizeThe preferred length of a line, used for auto breaking function arguments
tab_width: usizeThe amount of spaces in a tab
line_endings: LineEndingStyleThe type of line endings to generate
language: LanguageThe language to output bindings for
cpp_compat: boolInclude preprocessor defines in C bindings to ensure C++ compatibility
style: StyleThe style to declare structs, enums and unions in for C
sort_by: SortKeyDefault sort key for functions and constants.
usize_is_size_t: boolIf this option is true usize and isize will be converted into size_t and ptrdiff_t
instead of uintptr_t and intptr_t respectively.
parse: ParseConfigThe configuration options for parsing
export: ExportConfigThe configuration options for exporting
macro_expansion: MacroExpansionConfigThe configuration options for macros.
layout: LayoutConfigThe configuration options for type layouts.
function: FunctionConfigThe configuration options for functions
structure: StructConfigThe configuration options for structs
enumeration: EnumConfigThe configuration options for enums
constant: ConstantConfigThe configuration options for constants
defines: HashMap<String, String>Preprocessor defines to use when generating #ifdef’s for #cfg
documentation: boolInclude doc comments from Rust as documentation
documentation_style: DocumentationStyleHow documentation comments should be styled.
documentation_length: DocumentationLengthHow much of the documentation should be output for each item.
pointer: PtrConfigConfiguration options for pointers
only_target_dependencies: boolOnly download sources for dependencies needed for the target platform.
By default, cbindgen will fetch sources for dependencies used on any platform so that if a
type is defined in terms of a type from a dependency on another target (probably behind a
#[cfg]), cbindgen will be able to generate the appropriate binding as it can see the
nested type’s definition. However, this makes calling cbindgen slower, as it may have to
download a number of additional dependencies.
As an example, consider this Cargo.toml:
[target.'cfg(windows)'.dependencies]
windows = "0.7"with this declaration in one of the .rs files that cbindgen is asked to generate bindings
for:
#[cfg(windows)]
pub struct Error(windows::ErrorCode);With the default value (false), cbindgen will download the windows dependency even when
not compiling for Windows, and will thus be able to generate the binding for Error
(behind a #define).
If this value is instead to true, cbindgen will not download the windows dependency
if it’s not compiling for Windows, but will also fail to generate a Windows binding for
Error as it does not know the definition for ErrorCode.
The target can be chosen via the TARGET environment variable (if used
via the CLI, when ran from a build script cargo sets this variable
appropriately).
cython: CythonConfigConfiguration options specific to Cython.