Skip to main content

Object

Trait Object 

Source
pub trait Object: HasVtable {
    // Provided methods
    fn dtor(&mut self) { ... }
    fn destroy(&mut self) { ... }
    fn create_ui(&self) { ... }
    fn is_enable_instance(&self) -> bool { ... }
    fn create_property(&self, props: &mut MtPropertyList) { ... }
    fn get_dti(&self) -> &'static MtDti { ... }
    fn to_mt_object(&self) -> &MtObject { ... }
    fn to_mut_mt_object(&mut self) -> &mut MtObject { ... }
    unsafe fn read<T>(&self, offset: usize) -> T { ... }
    unsafe fn write<T: Copy>(&mut self, offset: usize, value: &T) { ... }
    unsafe fn get_ref<T>(&self, offset: usize) -> &T { ... }
    unsafe fn get_mut_ref<T>(&mut self, offset: usize) -> &mut T { ... }
}
Expand description

Behaviour shared by every MT Framework object, backed by the class’s vtable.

This trait exposes the common virtual functions found at the start of every MtObject vtable. It is implemented for concrete object types via #[derive(Object)]; each method dispatches through the corresponding vtable slot, so calling one runs the game’s own implementation for that object.

Provided Methods§

Source

fn dtor(&mut self)

Runs the destructor on self

§Safety

self is in an undefined state after this function is called. It is not safe to continue using the object.

Source

fn destroy(&mut self)

Runs the destructor on self and deallocates the object

§Safety

self is in an undefined state after this function is called. It is not safe to continue using the object.

Source

fn create_ui(&self)

Invokes the object’s UI-creation virtual function.

Note: Always unimplemented.

Source

fn is_enable_instance(&self) -> bool

Returns whether the object is enabled

Source

fn create_property(&self, props: &mut MtPropertyList)

Populates props with the object’s reflected properties.

Prefer the safe MtObject::get_properties wrapper, which builds and returns the list for you.

Source

fn get_dti(&self) -> &'static MtDti

Returns a reference to the object’s MtDti.

Equivalent to the MtObject::dti wrapper.

Source

fn to_mt_object(&self) -> &MtObject

Converts this object to a reference to an MtObject.

Source

fn to_mut_mt_object(&mut self) -> &mut MtObject

Converts this object to a mutable reference to an MtObject.

Source

unsafe fn read<T>(&self, offset: usize) -> T

Reads a value of type T from self at the given byte offset.

§Safety

The caller must ensure that self is valid for reads of type T at the given offset. offset must be a valid byte offset within self.

Source

unsafe fn write<T: Copy>(&mut self, offset: usize, value: &T)

Writes a value of type T to self at the given byte offset.

§Safety

The caller must ensure that self is valid for writes of type T at the given offset. offset must be a valid byte offset within self.

Source

unsafe fn get_ref<T>(&self, offset: usize) -> &T

Returns a reference to a value of type T within self at the given byte offset.

§Safety

The caller must ensure that self is valid for reads of type T at the given offset. offset must be a valid byte offset within self.

Source

unsafe fn get_mut_ref<T>(&mut self, offset: usize) -> &mut T

Returns a mutable reference to a value of type T within self at the given byte offset.

§Safety

The caller must ensure that self is valid for writes of type T at the given offset. offset must be a valid byte offset within self.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§