Trait ParseCallbacks
trait ParseCallbacks: fmt::Debug
A trait to allow configuring different kinds of types in different situations.
Provided Methods
fn will_parse_macro(self: &Self, _name: &str) -> MacroParsingBehaviorThis function will be run on every macro that is identified.
fn generated_name_override(self: &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.
fn generated_link_name_override(self: &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.
fn modify_macro(self: &Self, _name: &str, _tokens: &mut Vec<Token>)Modify the contents of a macro
fn int_macro(self: &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
Noneif you want the default to be chosen.fn str_macro(self: &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.
fn func_macro(self: &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.
The first parameter represents the name and argument list (including the parentheses) of the function-like macro. The second parameter represents the expansion of the macro as a sequence of tokens.
fn enum_variant_behavior(self: &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.
fn enum_variant_name(self: &Self, _enum_name: Option<&str>, _original_variant_name: &str, _variant_value: EnumVariantValue) -> Option<String>Allows to rename an enum variant, replacing
_original_variant_name.fn item_name(self: &Self, _item_info: ItemInfo<'_>) -> Option<String>Allows to rename an item, replacing
_item_info.name.fn header_file(self: &Self, _filename: &str)This will be called on every header filename passed to (
Builder::header)crate::Builder::header.fn include_file(self: &Self, _filename: &str)This will be called on every file inclusion, with the full path of the included file.
fn read_env_var(self: &Self, _key: &str)This will be called every time
bindgenreads an environment variable whether it has any content or not.fn blocklisted_type_implements_trait(self: &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.
None: use the default behaviorSome(ImplementsTrait::Yes):_nameimplements_derive_traitSome(ImplementsTrait::Manually): any type including_namecan't derive_derive_traitbut can implemented it manuallySome(ImplementsTrait::No):_namedoesn't implement_derive_trait
fn add_derives(self: &Self, _info: &DeriveInfo<'_>) -> Vec<String>Provide a list of custom derive attributes.
If no additional attributes are wanted, this function should return an empty
Vec.fn add_attributes(self: &Self, _info: &AttributeInfo<'_>) -> Vec<String>Provide a list of custom attributes.
If no additional attributes are wanted, this function should return an empty
Vec.fn process_comment(self: &Self, _comment: &str) -> Option<String>Process a source code comment.
fn field_visibility(self: &Self, _info: FieldInfo<'_>) -> Option<crate::FieldVisibilityKind>Potentially override the visibility of a composite type field.
Caution: This allows overriding standard C++ visibility inferred by
respect_cxx_access_specs.fn new_item_found(self: &Self, _id: DiscoveredItemId, _item: DiscoveredItem)This will get called everytime an item (currently struct, union, and alias) is found with some information about it
Implementors
impl ParseCallbacks for CargoCallbacks