Struct gdnative_core::object::TRef

source ·
pub struct TRef<'a, T: GodotObject, Own: Ownership = Shared> { /* private fields */ }
Expand description

A temporary safe pointer to Godot objects that tracks thread access status. TRef can be coerced into bare references with Deref.

See the type-level documentation on Ref for detailed documentation on the reference system of godot-rust.

Using as method arguments or return values

TRef<T, Shared> can be passed into methods.

Using as owner arguments in NativeScript methods

It’s possible to use TRef as the owner argument in NativeScript methods. This can make passing owner to methods easier.

Implementations§

Returns the underlying reference without thread access.

Performs a dynamic reference cast to target type, keeping the thread access info.

Performs a static reference upcast to a supertype that is guaranteed to be valid, keeping the thread access info.

This is guaranteed to be a no-op at runtime.

Convenience method to downcast to TInstance where self is the base object.

Persists this reference into a persistent Ref with the same thread access.

This is only available for non-Unique accesses.

Recovers a instance ID previously returned by Object::get_instance_id if the object is still alive.

Safety

During the entirety of 'a, the thread from which try_from_instance_id is called must have exclusive access to the underlying object, if it is still alive.

Recovers a instance ID previously returned by Object::get_instance_id if the object is still alive, and panics otherwise. This does NOT guarantee that the resulting reference is safe to use.

Panics

Panics if the given id refers to a destroyed object. For a non-panicking version, see try_from_instance_id.

Safety

During the entirety of 'a, the thread from which try_from_instance_id is called must have exclusive access to the underlying object, if it is still alive.

Trait Implementations§

Converts this type into a shared reference of the (usually inferred) input type.
Immutably borrows from an owned value. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.