Struct cbindgen::Config

source ·
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: bool

Add a #pragma once guard

§no_includes: bool

Generates 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: bool

Include 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: Braces

The style to use for braces

§line_length: usize

The preferred length of a line, used for auto breaking function arguments

§tab_width: usize

The amount of spaces in a tab

§line_endings: LineEndingStyle

The type of line endings to generate

§language: Language

The language to output bindings for

§cpp_compat: bool

Include preprocessor defines in C bindings to ensure C++ compatibility

§style: Style

The style to declare structs, enums and unions in for C

§sort_by: SortKey

Default sort key for functions and constants.

§usize_is_size_t: bool

If 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: ParseConfig

The configuration options for parsing

§export: ExportConfig

The configuration options for exporting

§macro_expansion: MacroExpansionConfig

The configuration options for macros.

§layout: LayoutConfig

The configuration options for type layouts.

§function: FunctionConfig

The configuration options for functions

§structure: StructConfig

The configuration options for structs

§enumeration: EnumConfig

The configuration options for enums

§constant: ConstantConfig

The configuration options for constants

§defines: HashMap<String, String>

Preprocessor defines to use when generating #ifdef’s for #cfg

§documentation: bool

Include doc comments from Rust as documentation

§documentation_style: DocumentationStyle

How documentation comments should be styled.

§documentation_length: DocumentationLength

How much of the documentation should be output for each item.

§pointer: PtrConfig

Configuration options for pointers

§only_target_dependencies: bool

Only 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: CythonConfig

Configuration options specific to Cython.

Implementations§

Trait Implementations§

source§

impl Clone for Config

source§

fn clone(&self) -> Config

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Config

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Config

source§

fn default() -> Config

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Configwhere Config: Default,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,