Struct bindgen::CargoCallbacks

source ·
pub struct CargoCallbacks { /* private fields */ }
Expand description

A ParseCallbacks implementation that will act on file includes by echoing a rerun-if-changed line and on env variable usage by echoing a rerun-if-env-changed line

When running inside a build.rs script, this can be used to make cargo invalidate the generated bindings whenever any of the files included from the header change:

use bindgen::builder;
let bindings = builder()
    .header("path/to/input/header")
    .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
    .generate();

Implementations§

source§

impl CargoCallbacks

source

pub fn new() -> Self

Create a new CargoCallbacks value.

source

pub fn rerun_on_header_files(self, doit: bool) -> Self

Whether Cargo should re-run the build script if any of the input header files has changed.

This option is enabled by default unless the deprecated CargoCallbacks constructor is used.

Trait Implementations§

source§

impl Debug for CargoCallbacks

source§

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

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

impl Default for CargoCallbacks

source§

fn default() -> Self

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

impl ParseCallbacks for CargoCallbacks

source§

fn header_file(&self, filename: &str)

This will be called on every header filename passed to (Builder::header)crate::Builder::header.
source§

fn include_file(&self, filename: &str)

This will be called on every file inclusion, with the full path of the included file.
source§

fn read_env_var(&self, key: &str)

This will be called every time bindgen reads an environment variable whether it has any content or not.
source§

fn will_parse_macro(&self, _name: &str) -> MacroParsingBehavior

This function will be run on every macro that is identified.
source§

fn generated_name_override(&self, _item_info: ItemInfo<'_>) -> Option<String>

This function will run for every extern variable and function. The returned value determines the name visible in the bindings.
This function will run for every extern variable and function. The returned value determines the link name in the bindings.
source§

fn int_macro(&self, _name: &str, _value: i64) -> Option<IntKind>

The integer kind an integer macro should have, given a name and the value of that macro, or None if you want the default to be chosen.
source§

fn str_macro(&self, _name: &str, _value: &[u8])

This will be run on every string macro. The callback cannot influence the further treatment of the macro, but may use the value to generate additional code or configuration.
source§

fn func_macro(&self, _name: &str, _value: &[&[u8]])

This will be run on every function-like macro. The callback cannot influence the further treatment of the macro, but may use the value to generate additional code or configuration. Read more
source§

fn enum_variant_behavior( &self, _enum_name: Option<&str>, _original_variant_name: &str, _variant_value: EnumVariantValue ) -> Option<EnumVariantCustomBehavior>

This function should return whether, given an enum variant name, and value, this enum variant will forcibly be a constant.
source§

fn enum_variant_name( &self, _enum_name: Option<&str>, _original_variant_name: &str, _variant_value: EnumVariantValue ) -> Option<String>

Allows to rename an enum variant, replacing _original_variant_name.
source§

fn item_name(&self, _original_item_name: &str) -> Option<String>

Allows to rename an item, replacing _original_item_name.
source§

fn blocklisted_type_implements_trait( &self, _name: &str, _derive_trait: DeriveTrait ) -> Option<ImplementsTrait>

This will be called to determine whether a particular blocklisted type implements a trait or not. This will be used to implement traits on other types containing the blocklisted type. Read more
source§

fn add_derives(&self, _info: &DeriveInfo<'_>) -> Vec<String>

Provide a list of custom derive attributes. Read more
source§

fn process_comment(&self, _comment: &str) -> Option<String>

Process a source code comment.
source§

fn field_visibility(&self, _info: FieldInfo<'_>) -> Option<FieldVisibilityKind>

Potentially override the visibility of a composite type field. Read more
source§

fn wrap_as_variadic_fn(&self, _name: &str) -> Option<String>

Process a function name that as exactly one va_list argument to be wrapped as a variadic function with the wrapped static function feature. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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 T
where 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, U> TryFrom<U> for T
where 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 T
where 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.