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
sourceimpl<'a, T: GodotObject, Own: Ownership> TRef<'a, T, Own>
impl<'a, T: GodotObject, Own: Ownership> TRef<'a, T, Own>
sourcepub fn cast<U>(self) -> Option<TRef<'a, U, Own>> where
U: GodotObject + SubClass<T>,
pub fn cast<U>(self) -> Option<TRef<'a, U, Own>> where
U: GodotObject + SubClass<T>,
Performs a dynamic reference cast to target type, keeping the thread access info.
sourcepub fn upcast<U>(&self) -> TRef<'a, U, Own> where
U: GodotObject,
T: SubClass<U>,
pub fn upcast<U>(&self) -> TRef<'a, U, Own> where
U: GodotObject,
T: SubClass<U>,
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.
sourcepub fn cast_instance<C>(self) -> Option<TInstance<'a, C, Own>> where
C: NativeClass<Base = T>,
pub fn cast_instance<C>(self) -> Option<TInstance<'a, C, Own>> where
C: NativeClass<Base = T>,
Convenience method to downcast to TInstance where self is the base object.
sourceimpl<'a, Kind, T, Own> TRef<'a, T, Own> where
Kind: Memory,
T: GodotObject<Memory = Kind>,
Own: NonUniqueOwnership,
impl<'a, Kind, T, Own> TRef<'a, T, Own> where
Kind: Memory,
T: GodotObject<Memory = Kind>,
Own: NonUniqueOwnership,
sourceimpl<'a, T: GodotObject> TRef<'a, T, Shared>
impl<'a, T: GodotObject> TRef<'a, T, Shared>
sourcepub unsafe fn try_from_instance_id(id: i64) -> Option<Self>
pub unsafe fn try_from_instance_id(id: i64) -> Option<Self>
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.
sourcepub unsafe fn from_instance_id(id: i64) -> Self
pub unsafe fn from_instance_id(id: i64) -> Self
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
sourceimpl<'a, T: GodotObject, Own: Ownership> AsRef<T> for TRef<'a, T, Own>
impl<'a, T: GodotObject, Own: Ownership> AsRef<T> for TRef<'a, T, Own>
sourceimpl<'a, T: GodotObject, Own: Ownership> Borrow<T> for TRef<'a, T, Own>
impl<'a, T: GodotObject, Own: Ownership> Borrow<T> for TRef<'a, T, Own>
sourceimpl<'a, T: GodotObject, Own: Ownership> Clone for TRef<'a, T, Own>
impl<'a, T: GodotObject, Own: Ownership> Clone for TRef<'a, T, Own>
sourceimpl<'a, T: GodotObject, Own: Ownership> Debug for TRef<'a, T, Own>
impl<'a, T: GodotObject, Own: Ownership> Debug for TRef<'a, T, Own>
sourceimpl<'a, T: GodotObject, Own: Ownership> Deref for TRef<'a, T, Own>
impl<'a, T: GodotObject, Own: Ownership> Deref for TRef<'a, T, Own>
sourceimpl<'a, T: GodotObject> ToVariant for TRef<'a, T, Shared>
impl<'a, T: GodotObject> ToVariant for TRef<'a, T, Shared>
fn to_variant(&self) -> Variant
impl<'a, T, U> AsArg<U> for TRef<'a, T, Shared> where
T: GodotObject + SubClass<U>,
U: GodotObject,
impl<'a, T: GodotObject, Own: Ownership> Copy for TRef<'a, T, Own>
impl<'a, T, Own> OwnerArg<'a, T, Own> for TRef<'a, T, Own> where
T: GodotObject,
Own: Ownership + 'static,
Auto Trait Implementations
impl<'a, T, Own> RefUnwindSafe for TRef<'a, T, Own> where
Own: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, Own> Send for TRef<'a, T, Own> where
Own: Send,
T: Sync,
impl<'a, T, Own> Sync for TRef<'a, T, Own> where
Own: Sync,
T: Sync,
impl<'a, T, Own> Unpin for TRef<'a, T, Own> where
Own: Unpin,
impl<'a, T, Own> UnwindSafe for TRef<'a, T, Own> where
Own: UnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more