#[repr(transparent)]pub struct TypeContainer {
pub handle: NonNull<BNTypeContainer>,
}
Expand description
A TypeContainer
is a generic interface to access various Binary Ninja models
that contain types. Types are stored with both a unique id and a unique name.
Fields§
§handle: NonNull<BNTypeContainer>
Implementations§
source§impl TypeContainer
impl TypeContainer
sourcepub fn id(&self) -> BnString
pub fn id(&self) -> BnString
Get an id string for the Type Container. This will be unique within a given analysis session, but may not be globally unique.
sourcepub fn container_type(&self) -> TypeContainerType
pub fn container_type(&self) -> TypeContainerType
Get the type of underlying model the Type Container is accessing.
sourcepub fn is_mutable(&self) -> bool
pub fn is_mutable(&self) -> bool
If the Type Container supports mutable operations (add, rename, delete)
sourcepub fn platform(&self) -> Ref<Platform>
pub fn platform(&self) -> Ref<Platform>
Get the Platform object associated with this Type Container. All Type Containers have exactly one associated Platform (as opposed to, e.g. Type Libraries).
sourcepub fn add_types<I, T>(&self, types: I) -> bool
pub fn add_types<I, T>(&self, types: I) -> bool
Add or update types to a Type Container. If the Type Container already contains a type with the same name as a type being added, the existing type will be replaced with the definition given to this function, and references will be updated in the source model.
pub fn add_types_with_progress<I, T, P>(&self, types: I, progress: P) -> bool
sourcepub fn rename_type<T: Into<QualifiedName>, S: BnStrCompatible>(
&self,
name: T,
type_id: S,
) -> bool
pub fn rename_type<T: Into<QualifiedName>, S: BnStrCompatible>( &self, name: T, type_id: S, ) -> bool
Rename a type in the Type Container. All references to this type will be updated (by id) to use the new name.
Returns true if the type was renamed.
sourcepub fn delete_type<S: BnStrCompatible>(&self, type_id: S) -> bool
pub fn delete_type<S: BnStrCompatible>(&self, type_id: S) -> bool
Delete a type in the Type Container. Behavior of references to this type is not specified and you may end up with broken references if any still exist.
Returns true if the type was deleted.
sourcepub fn type_id<T: Into<QualifiedName>>(&self, name: T) -> Option<BnString>
pub fn type_id<T: Into<QualifiedName>>(&self, name: T) -> Option<BnString>
Get the unique id of the type in the Type Container with the given name.
If no type with that name exists, returns None.
sourcepub fn type_name<S: BnStrCompatible>(&self, type_id: S) -> Option<QualifiedName>
pub fn type_name<S: BnStrCompatible>(&self, type_id: S) -> Option<QualifiedName>
Get the unique name of the type in the Type Container with the given id.
If no type with that id exists, returns None.
sourcepub fn type_by_id<S: BnStrCompatible>(&self, type_id: S) -> Option<Ref<Type>>
pub fn type_by_id<S: BnStrCompatible>(&self, type_id: S) -> Option<Ref<Type>>
Get the definition of the type in the Type Container with the given id.
If no type with that id exists, returns None.
sourcepub fn type_by_name<T: Into<QualifiedName>>(&self, name: T) -> Option<Ref<Type>>
pub fn type_by_name<T: Into<QualifiedName>>(&self, name: T) -> Option<Ref<Type>>
Get the definition of the type in the Type Container with the given name.
If no type with that name exists, returns None.
sourcepub fn types(&self) -> Option<HashMap<String, (QualifiedName, Ref<Type>)>>
pub fn types(&self) -> Option<HashMap<String, (QualifiedName, Ref<Type>)>>
Get a mapping of all types in a Type Container.
sourcepub fn type_names(&self) -> Option<Array<QualifiedName>>
pub fn type_names(&self) -> Option<Array<QualifiedName>>
Get all type names in a Type Container.
sourcepub fn type_names_and_ids(
&self,
) -> Option<(Array<BnString>, Array<QualifiedName>)>
pub fn type_names_and_ids( &self, ) -> Option<(Array<BnString>, Array<QualifiedName>)>
Get a mapping of all type ids and type names in a Type Container.
sourcepub fn parse_type_string<S: BnStrCompatible>(
&self,
source: S,
import_dependencies: bool,
) -> Result<QualifiedNameAndType, Array<TypeParserError>>
pub fn parse_type_string<S: BnStrCompatible>( &self, source: S, import_dependencies: bool, ) -> Result<QualifiedNameAndType, Array<TypeParserError>>
Parse a single type and name from a string containing their definition, with knowledge of the types in the Type Container.
source
- Source code to parseimport_dependencies
- If Type Library / Type Archive types should be imported during parsing
sourcepub fn parse_types_from_source<S, F, O, D, A>(
&self,
source: S,
filename: F,
options: O,
include_directories: D,
auto_type_source: A,
import_dependencies: bool,
) -> Result<TypeParserResult, Array<TypeParserError>>where
S: BnStrCompatible,
F: BnStrCompatible,
O: IntoIterator,
O::Item: BnStrCompatible,
D: IntoIterator,
D::Item: BnStrCompatible,
A: BnStrCompatible,
pub fn parse_types_from_source<S, F, O, D, A>(
&self,
source: S,
filename: F,
options: O,
include_directories: D,
auto_type_source: A,
import_dependencies: bool,
) -> Result<TypeParserResult, Array<TypeParserError>>where
S: BnStrCompatible,
F: BnStrCompatible,
O: IntoIterator,
O::Item: BnStrCompatible,
D: IntoIterator,
D::Item: BnStrCompatible,
A: BnStrCompatible,
Parse an entire block of source into types, variables, and functions, with knowledge of the types in the Type Container.
source
- Source code to parsefile_name
- Name of the file containing the source (optional: exists on disk)options
- String arguments to pass as options, e.g. command line argumentsinclude_dirs
- List of directories to include in the header search pathauto_type_source
- Source of types if used for automatically generated typesimport_dependencies
- If Type Library / Type Archive types should be imported during parsing