#[repr(transparent)]pub struct Type {
pub handle: *mut BNType,
}Expand description
The core model for types in Binary Ninja.
A Type is how we model the storage of a Variable or crate::variable::DataVariable as
well as propagate information such as the constness of a variable. Types are also used to declare
function signatures, such as the FunctionParameter’s and return type.
Types are immutable. To change a type, you must create a new one either using TypeBuilder or
one of the helper functions:
Type::voidType::boolType::charType::wide_charType::int,Type::named_intType::float,Type::named_floatType::arrayType::enumerationType::structureType::named_type,Type::named_type_from_typeType::function,Type::function_with_optsType::pointer,Type::const_pointer,Type::pointer_of_width,Type::pointer_with_options
§Example
As an example, defining a named type within a BinaryView:
let bv = binaryninja::load("example.bin").unwrap();
let my_custom_type_1 = Type::named_int(5, false, "my_w");
let my_custom_type_2 = Type::int(5, false);
bv.define_user_type("int_1", &my_custom_type_1);
bv.define_user_type("int_2", &my_custom_type_2);Fields§
§handle: *mut BNTypeImplementations§
Source§impl Type
impl Type
pub unsafe fn from_raw(handle: *mut BNType) -> Self
pub unsafe fn ref_from_raw(handle: *mut BNType) -> Ref<Self>
pub fn to_builder(&self) -> TypeBuilder
pub fn type_class(&self) -> TypeClass
pub fn alignment(&self) -> usize
pub fn is_signed(&self) -> Conf<bool>
pub fn is_const(&self) -> Conf<bool>
pub fn is_volatile(&self) -> Conf<bool>
pub fn is_floating_point(&self) -> bool
pub fn child_type(&self) -> Option<Conf<Ref<Type>>>
Sourcepub fn element_type(&self) -> Option<Conf<Ref<Type>>>
pub fn element_type(&self) -> Option<Conf<Ref<Type>>>
This is an alias for Self::child_type.
Sourcepub fn return_value(&self) -> Option<Conf<Ref<Type>>>
pub fn return_value(&self) -> Option<Conf<Ref<Type>>>
This is an alias for Self::child_type.
pub fn calling_convention(&self) -> Option<Conf<Ref<CoreCallingConvention>>>
pub fn parameters(&self) -> Option<Vec<FunctionParameter>>
pub fn has_variable_arguments(&self) -> Conf<bool>
pub fn can_return(&self) -> Conf<bool>
pub fn pure(&self) -> Conf<bool>
pub fn get_structure(&self) -> Option<Ref<Structure>>
pub fn get_enumeration(&self) -> Option<Ref<Enumeration>>
pub fn get_named_type_reference(&self) -> Option<Ref<NamedTypeReference>>
pub fn count(&self) -> u64
pub fn offset(&self) -> u64
pub fn stack_adjustment(&self) -> Conf<i64>
pub fn registered_name(&self) -> Option<Ref<NamedTypeReference>>
pub fn pointer_base_type(&self) -> BNPointerBaseType
pub fn pointer_base_offset(&self) -> i64
pub fn void() -> Ref<Self>
pub fn bool() -> Ref<Self>
pub fn char() -> Ref<Self>
pub fn wide_char(width: usize) -> Ref<Self>
pub fn int(width: usize, is_signed: bool) -> Ref<Self>
pub fn named_int(width: usize, is_signed: bool, alt_name: &str) -> Ref<Self>
pub fn float(width: usize) -> Ref<Self>
pub fn named_float(width: usize, alt_name: &str) -> Ref<Self>
pub fn array<'a, T: Into<Conf<&'a Type>>>(ty: T, count: u64) -> Ref<Self>
Sourcepub fn enumeration<T: Into<Conf<bool>>>(
enumeration: &Enumeration,
width: NonZeroUsize,
is_signed: T,
) -> Ref<Self>
pub fn enumeration<T: Into<Conf<bool>>>( enumeration: &Enumeration, width: NonZeroUsize, is_signed: T, ) -> Ref<Self>
§NOTE
The C/C++ APIs require an associated architecture, but in the core we only query the default_int_size if the given width is 0.
For simplicity’s sake, that convention isn’t followed, and you can query Architecture::default_integer_size if you need to.
pub fn structure(structure: &Structure) -> Ref<Self>
pub fn named_type(type_reference: &NamedTypeReference) -> Ref<Self>
pub fn named_type_from_type<T: Into<QualifiedName>>( name: T, t: &Type, ) -> Ref<Self>
pub fn function<'a, T: Into<Conf<&'a Type>>>( return_type: T, parameters: Vec<FunctionParameter>, variable_arguments: bool, ) -> Ref<Self>
pub fn function_with_opts<'a, T: Into<Conf<&'a Type>>, C: Into<Conf<Ref<CoreCallingConvention>>>>( return_type: T, parameters: &[FunctionParameter], variable_arguments: bool, calling_convention: C, stack_adjust: Conf<i64>, ) -> Ref<Self>
pub fn pointer<'a, A: Architecture, T: Into<Conf<&'a Type>>>( arch: &A, ty: T, ) -> Ref<Self>
pub fn const_pointer<'a, A: Architecture, T: Into<Conf<&'a Type>>>( arch: &A, ty: T, ) -> Ref<Self>
pub fn pointer_with_options<'a, A: Architecture, T: Into<Conf<&'a Type>>>( arch: &A, ty: T, is_const: bool, is_volatile: bool, ref_type: Option<ReferenceType>, ) -> Ref<Self>
pub fn pointer_of_width<'a, T: Into<Conf<&'a Type>>>( ty: T, size: usize, is_const: bool, is_volatile: bool, ref_type: Option<ReferenceType>, ) -> Ref<Self>
pub fn generate_auto_demangled_type_id<T: Into<QualifiedName>>( name: T, ) -> String
Trait Implementations§
Source§impl CoreArrayProvider for Type
impl CoreArrayProvider for Type
Source§impl ToOwned for Type
impl ToOwned for Type
impl Eq for Type
impl Send for Type
impl Sync for Type
Auto Trait Implementations§
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
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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