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§
Sourcefn dtor(&mut self)
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.
Sourcefn destroy(&mut self)
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.
Sourcefn create_ui(&self)
fn create_ui(&self)
Invokes the object’s UI-creation virtual function.
Note: Always unimplemented.
Sourcefn is_enable_instance(&self) -> bool
fn is_enable_instance(&self) -> bool
Returns whether the object is enabled
Sourcefn create_property(&self, props: &mut MtPropertyList)
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.
Sourcefn get_dti(&self) -> &'static MtDti
fn get_dti(&self) -> &'static MtDti
Returns a reference to the object’s MtDti.
Equivalent to the MtObject::dti wrapper.
Sourcefn to_mt_object(&self) -> &MtObject
fn to_mt_object(&self) -> &MtObject
Converts this object to a reference to an MtObject.
Sourcefn to_mut_mt_object(&mut self) -> &mut MtObject
fn to_mut_mt_object(&mut self) -> &mut MtObject
Converts this object to a mutable reference to an MtObject.
Sourceunsafe fn read<T>(&self, offset: usize) -> T
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.
Sourceunsafe fn write<T: Copy>(&mut self, offset: usize, value: &T)
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.
Sourceunsafe fn get_ref<T>(&self, offset: usize) -> &T
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.
Sourceunsafe fn get_mut_ref<T>(&mut self, offset: usize) -> &mut T
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".