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
impl CargoCallbacks
Sourcepub fn new() -> CargoCallbacks
pub fn new() -> CargoCallbacks
Create a new CargoCallbacks
value.
Sourcepub fn rerun_on_header_files(self, doit: bool) -> CargoCallbacks
pub fn rerun_on_header_files(self, doit: bool) -> CargoCallbacks
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
impl Debug for CargoCallbacks
Source§impl Default for CargoCallbacks
impl Default for CargoCallbacks
Source§fn default() -> CargoCallbacks
fn default() -> CargoCallbacks
Returns the “default value” for a type. Read more
Source§impl ParseCallbacks for CargoCallbacks
impl ParseCallbacks for CargoCallbacks
Source§fn header_file(&self, filename: &str)
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)
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)
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
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>
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.
Source§fn generated_link_name_override(
&self,
_item_info: ItemInfo<'_>,
) -> Option<String>
fn generated_link_name_override( &self, _item_info: ItemInfo<'_>, ) -> Option<String>
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>
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])
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]])
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>
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>
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>
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<CanDerive>
fn blocklisted_type_implements_trait( &self, _name: &str, _derive_trait: DeriveTrait, ) -> Option<CanDerive>
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>
fn add_derives(&self, _info: &DeriveInfo<'_>) -> Vec<String>
Provide a list of custom derive attributes. Read more
Source§fn add_attributes(&self, _info: &AttributeInfo<'_>) -> Vec<String>
fn add_attributes(&self, _info: &AttributeInfo<'_>) -> Vec<String>
Provide a list of custom attributes. Read more
Source§fn field_visibility(&self, _info: FieldInfo<'_>) -> Option<FieldVisibilityKind>
fn field_visibility(&self, _info: FieldInfo<'_>) -> Option<FieldVisibilityKind>
Potentially override the visibility of a composite type field. Read more
Source§fn new_item_found(&self, _id: DiscoveredItemId, _item: DiscoveredItem)
fn new_item_found(&self, _id: DiscoveredItemId, _item: DiscoveredItem)
This will get called everytime an item (currently struct, union, and alias) is found with some information about it
Auto Trait Implementations§
impl Freeze for CargoCallbacks
impl RefUnwindSafe for CargoCallbacks
impl Send for CargoCallbacks
impl Sync for CargoCallbacks
impl Unpin for CargoCallbacks
impl UnwindSafe for CargoCallbacks
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more