unity::il2cpp::object

Struct Il2CppObject

source
#[repr(C)]
pub struct Il2CppObject<T> { pub klass: &'static mut Il2CppClass, pub fields: T, /* private fields */ }
Expand description

Wrapper structure for a class instance provided by Il2Cpp.

It contains a pointer to the class it represents as well as its own copy of the fields in the class.
Every class instance is represented by this type and passed by reference.

Define the fields of the class as a structure and pass them as a generic.

Example:

pub fn hooked_method(proc: &Il2CppObject<ProcInst>) {
// ...
}

Fields§

§klass: &'static mut Il2CppClass

The class this instance refers to. Be aware that editing it means editing every other object using the same class.
Use carefully.

§fields: T

Implementations§

source§

impl<T> Il2CppObject<T>

source

pub fn get_class(&self) -> &Il2CppClass

source

pub fn get_class_mut(&mut self) -> &mut Il2CppClass

source

pub fn from_class(class: &Il2CppClass) -> Il2CppResult<&'static mut T>

Create a unique Il2CppObject instance of the Il2CppClass provided.

source§

impl Il2CppObject<SystemString>

source

pub fn new<'a>(string: impl AsRef<str>) -> &'a Il2CppString

Create a new instance of a SystemString using the provided value.

Internally turned into a CString, so make sure the provided value is a valid UTF-8 string.

Example:

let string = Il2CppString::new("A new string");
```j
source

pub fn new_static(string: impl AsRef<str>) -> &'static mut Il2CppString

source

pub fn get_string(&self) -> Result<String, FromUtf16Error>

👎Deprecated: Use Il2CppString::to_string instead
source

pub fn to_string(&self) -> String

source

pub fn to_lowercase(&self) -> &mut Il2CppString

source

pub fn starts_with<'a>(&self, value: impl Into<&'a Il2CppString>) -> bool

source

pub fn contains<'a>(&self, value: impl Into<&'a Il2CppString>) -> bool

source

pub fn replace<'a>( &mut self, old_value: impl Into<&'a Il2CppString>, new_value: impl Into<&'a Il2CppString>, ) -> &mut Il2CppString

source

pub fn clone(&self) -> &Il2CppString

Provides a new instance of the Il2CppString, separate from the original.

source

pub fn clone_mut(&mut self) -> &mut Il2CppString

source

pub fn copy(&self) -> &Il2CppString

source

pub fn copy_mut(&mut self) -> &mut Il2CppString

source

pub fn get_hash_code(&self) -> i32

Trait Implementations§

source§

impl<T> AsMut<T> for Il2CppObject<T>

source§

fn as_mut(&mut self) -> &mut T

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl<T> AsRef<T> for Il2CppObject<T>

source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T> Deref for Il2CppObject<T>

source§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T> DerefMut for Il2CppObject<T>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<T> Freeze for Il2CppObject<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Il2CppObject<T>
where T: RefUnwindSafe,

§

impl<T> !Send for Il2CppObject<T>

§

impl<T> !Sync for Il2CppObject<T>

§

impl<T> Unpin for Il2CppObject<T>
where T: Unpin,

§

impl<T> !UnwindSafe for Il2CppObject<T>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T> ToString for T
where T: Display + ?Sized,

§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.