binaryninja::type_container

Struct TypeContainer

source
#[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

source

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.

source

pub fn name(&self) -> BnString

Get a user-friendly name for the Type Container.

source

pub fn container_type(&self) -> TypeContainerType

Get the type of underlying model the Type Container is accessing.

source

pub fn is_mutable(&self) -> bool

If the Type Container supports mutable operations (add, rename, delete)

source

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).

source

pub fn add_types<I, T>(&self, types: I) -> bool
where I: IntoIterator<Item = T>, T: Into<QualifiedNameAndType>,

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.

source

pub fn add_types_with_progress<I, T, P>(&self, types: I, progress: P) -> bool

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn types(&self) -> Option<HashMap<String, (QualifiedName, Ref<Type>)>>

Get a mapping of all types in a Type Container.

source

pub fn type_ids(&self) -> Option<Array<BnString>>

Get all type ids in a Type Container.

source

pub fn type_names(&self) -> Option<Array<QualifiedName>>

Get all type names in a Type Container.

source

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.

source

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 parse
  • import_dependencies - If Type Library / Type Archive types should be imported during parsing
source

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>>

Parse an entire block of source into types, variables, and functions, with knowledge of the types in the Type Container.

  • source - Source code to parse
  • file_name - Name of the file containing the source (optional: exists on disk)
  • options - String arguments to pass as options, e.g. command line arguments
  • include_dirs - List of directories to include in the header search path
  • auto_type_source - Source of types if used for automatically generated types
  • import_dependencies - If Type Library / Type Archive types should be imported during parsing

Trait Implementations§

source§

impl Clone for TypeContainer

source§

fn clone(&self) -> Self

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 TypeContainer

source§

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

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

impl Drop for TypeContainer

source§

fn drop(&mut self)

Executes the destructor for this type. 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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit #126799)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

source§

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 T
where U: Into<T>,

source§

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>,

source§

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.