Skip to main content

Class

Struct Class 

Source
pub struct Class {
Show 31 fields pub address: *mut c_void, pub image: *mut c_void, pub token: u32, pub name: String, pub parent: Option<String>, pub namespace: String, pub is_enum: bool, pub is_generic: bool, pub is_inflated: bool, pub is_interface: bool, pub is_abstract: bool, pub is_blittable: bool, pub is_valuetype: bool, pub flags: i32, pub rank: i32, pub instance_size: i32, pub array_element_size: i32, pub num_fields_count: usize, pub enum_basetype: *mut c_void, pub static_field_data: *mut c_void, pub assembly_name: String, pub assembly: Option<Arc<Assembly>>, pub fields: Vec<Field>, pub methods: Vec<Method>, pub properties: Vec<Property>, pub interfaces: Vec<*mut c_void>, pub nested_types: Vec<*mut c_void>, pub element_class: *mut c_void, pub declaring_type: *mut c_void, pub ty: *mut c_void, pub object: *mut c_void,
}
Expand description

Hydrated IL2CPP class metadata.

A Class is the main entry point for metadata-driven workflows after fetching an crate::structs::Assembly from the cache. From here you can locate methods, fields, properties, create objects, or search for live instances in the scene.

Fields§

§address: *mut c_void

Pointer to the internal IL2CPP class structure

§image: *mut c_void

Pointer to the image defining this class

§token: u32

Metadata token for this class

§name: String

Name of the class

§parent: Option<String>

Name of the parent class (if any)

§namespace: String

Namespace of the class

§is_enum: bool

Whether the class is an enum

§is_generic: bool

Whether the class is generic

§is_inflated: bool

Whether the class is an inflated generic type

§is_interface: bool

Whether the class is an interface

§is_abstract: bool

Whether the class is abstract

§is_blittable: bool

Whether the class is blittable

§is_valuetype: bool

Whether the class is a value type

§flags: i32

Flags associated with the class

§rank: i32

Rank of the class (if array)

§instance_size: i32

Size of an instance of this class

§array_element_size: i32

Size of array elements (if this is an array class)

§num_fields_count: usize

Number of fields in this class

§enum_basetype: *mut c_void

Enum base type pointer (if this is an enum)

§static_field_data: *mut c_void

Pointer to static field data

§assembly_name: String

Name of the assembly defining this class

§assembly: Option<Arc<Assembly>>

Assembly that this class belongs to

§fields: Vec<Field>

List of fields in this class

§methods: Vec<Method>

List of methods in this class

§properties: Vec<Property>

List of properties in this class

§interfaces: Vec<*mut c_void>

List of interfaces implemented by this class

§nested_types: Vec<*mut c_void>

List of nested types within this class

§element_class: *mut c_void

Element class (if this is an array class)

§declaring_type: *mut c_void

Declaring type (if this is a nested class)

§ty: *mut c_void

Pointer to the Type object representing this class

§object: *mut c_void

Pointer to the System.Type object

Implementations§

Source§

impl Class

Source

pub fn dump_string(&self) -> String

Generates a string representation of the class, including fields and methods

§Returns
  • String - The formatted string dump of the class
Source

pub fn create_instance(&self) -> Result<Object, String>

Creates a managed instance using System.Activator.CreateInstance.

Use this when you want constructor semantics rather than raw allocation.

Source

pub fn new_object(&self) -> Result<Object, String>

Allocates a new object of this class via il2cpp_object_new.

This is the low-level allocation path and does not imply constructor execution.

Source

pub fn create_scriptable_instance(&self) -> Result<Object, String>

Creates a ScriptableObject instance of this class.

Source

pub fn find_objects_of_type(&self, include_inactive: bool) -> Vec<Object>

Finds live objects of this type in the scene.

This wraps UnityEngine.Object.FindObjectsOfType and returns bound Object wrappers for each match.

Source

pub fn method<S: MethodSelector>(&self, selector: S) -> Option<Method>

Finds a method in this class or its parent chain.

Selectors may match by name, by name plus parameter type names, or by name plus parameter count.

Source

pub fn field(&self, name: &str) -> Option<Field>

Finds a field in this class or its parent chain.

Source

pub fn property(&self, name: &str) -> Option<Property>

Finds a property in this class or its parent chain.

Source

pub fn init(&self)

Initializes the class if it hasn’t been initialized yet

Calls il2cpp_runtime_class_init.

Source

pub fn has_references(&self) -> bool

Checks if the class has references

§Returns
  • bool - True if class has references
Source

pub fn is_assignable_from(&self, other: &Class) -> bool

Checks if this class is assignable from another class

§Arguments
  • other - The other class to check against
§Returns
  • bool - True if assignable
Source

pub fn is_subclass_of(&self, other: &Class, check_interfaces: bool) -> bool

Checks if this class is a subclass of another class

§Arguments
  • other - The prospective parent class
  • check_interfaces - Whether to check interfaces as well
§Returns
  • bool - True if it is a subclass
Source

pub fn get_value_size(&self) -> i32

Gets the size of the value type

§Returns
  • i32 - The size of the value type in bytes
Source

pub fn has_parent(&self, parent: &Class) -> bool

Checks if this class has the specified parent class (wrapper for il2cpp_class_has_parent)

§Arguments
  • parent - The parent class to check for
§Returns
  • bool - True if parent exists in the inheritance hierarchy
Source

pub fn has_attribute(&self, attr_class: &Class) -> bool

Checks if this class has the specified attribute (wrapper for il2cpp_class_has_attribute)

§Arguments
  • attr_class - The attribute class to check for
§Returns
  • bool - True if the class has the attribute
Source

pub fn inflate(&self, classes: &[&Class]) -> Result<Arc<Class>, String>

Inflates a generic class with the specified type arguments to create a concrete generic type.

§Arguments
  • classes - Slice of classes to use as type arguments
§Returns
  • Result<Arc<Class>, String> - The inflated concrete class

Trait Implementations§

Source§

impl Clone for Class

Source§

fn clone(&self) -> Class

Returns a duplicate 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 Class

Source§

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

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

impl Display for Class

Source§

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

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

impl Send for Class

Source§

impl Sync for Class

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.