#[repr(C)]pub struct RawObject<T> { /* private fields */ }
Expand description
An opaque struct representing Godot objects. This should never be created on the stack.
This is an internal interface. Users are expected to use references to named generated types instead.
Implementations§
Source§impl<T: GodotObject> RawObject<T>
impl<T: GodotObject> RawObject<T>
Sourcepub unsafe fn from_sys_ref_unchecked<'a>(obj: NonNull<godot_object>) -> &'a Self
pub unsafe fn from_sys_ref_unchecked<'a>(obj: NonNull<godot_object>) -> &'a Self
Creates a typed reference from a pointer, without checking the type of the pointer.
§Safety
The obj
pointer must be pointing to a valid Godot object of type T
during the
entirety of 'a
.
Sourcepub unsafe fn try_from_sys_ref<'a>(
obj: NonNull<godot_object>,
) -> Option<&'a Self>
pub unsafe fn try_from_sys_ref<'a>( obj: NonNull<godot_object>, ) -> Option<&'a Self>
Creates a typed reference from a pointer if the pointer is pointing to an object of
the correct type. Returns None
otherwise.
§Safety
The obj
pointer must be pointing to a valid Godot object during the entirety of 'a
.
Sourcepub fn sys(&self) -> NonNull<godot_object>
pub fn sys(&self) -> NonNull<godot_object>
Casts a reference to this opaque object to *const sys::godot_object
.
Sourcepub fn is_class<U: GodotObject>(&self) -> bool
pub fn is_class<U: GodotObject>(&self) -> bool
Checks whether the object is of a certain Godot class.
Sourcepub fn is_class_by_name(&self, class_name: &str) -> bool
pub fn is_class_by_name(&self, class_name: &str) -> bool
Checks whether the object is of a certain Godot class by name.
Sourcepub fn class_name(&self) -> String
pub fn class_name(&self) -> String
Returns the class name of this object dynamically using Object::get_class
.
Sourcepub fn cast<U>(&self) -> Option<&RawObject<U>>where
U: GodotObject,
pub fn cast<U>(&self) -> Option<&RawObject<U>>where
U: GodotObject,
Attempt to cast a Godot object to a different class type.
Sourcepub unsafe fn cast_unchecked<U>(&self) -> &RawObject<U>where
U: GodotObject,
pub unsafe fn cast_unchecked<U>(&self) -> &RawObject<U>where
U: GodotObject,
Attempt to cast a Godot object to a different class type without checking the type at runtime.
§Safety
The types must be compatible.
Source§impl<T: GodotObject<Memory = RefCounted>> RawObject<T>
impl<T: GodotObject<Memory = RefCounted>> RawObject<T>
Sourcepub unsafe fn unref(&self) -> bool
pub unsafe fn unref(&self) -> bool
Decrease the reference count of the object. Returns true
if this is the last
reference.
§Safety
Further operations must not be performed on the same reference if this is the last reference.
Sourcepub unsafe fn unref_and_free_if_last(&self) -> bool
pub unsafe fn unref_and_free_if_last(&self) -> bool
Decrease the reference count of the object. Frees the object and returns true
if this
is the last reference.
§Safety
Further operations must not be performed on the same reference if this is the last reference.
Sourcepub unsafe fn init_ref_count(&self)
pub unsafe fn init_ref_count(&self)
Initialize the reference count of the object.
§Safety
This function assumes that no other references are held at the time.