Struct RawObject

Source
#[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>

Source

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.

Source

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.

Source

pub fn sys(&self) -> NonNull<godot_object>

Casts a reference to this opaque object to *const sys::godot_object.

Source

pub fn is_class<U: GodotObject>(&self) -> bool

Checks whether the object is of a certain Godot class.

Source

pub fn is_class_by_name(&self, class_name: &str) -> bool

Checks whether the object is of a certain Godot class by name.

Source

pub fn class_name(&self) -> String

Returns the class name of this object dynamically using Object::get_class.

Source

pub fn cast<U>(&self) -> Option<&RawObject<U>>
where U: GodotObject,

Attempt to cast a Godot object to a different class type.

Source

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

pub unsafe fn free(&self)

Free the underlying object.

§Safety

Further operations must not be performed on the same reference.

Source§

impl<T: GodotObject<Memory = RefCounted>> RawObject<T>

Source

pub fn add_ref(&self)

Increase the reference count of the object.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<T: GodotObject> Debug for RawObject<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for RawObject<T>

§

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

§

impl<T> !Send for RawObject<T>

§

impl<T> !Sync for RawObject<T>

§

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

§

impl<T> UnwindSafe for RawObject<T>
where T: UnwindSafe,

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> 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, 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.