Struct gdnative_core::object::TRef[][src]

pub struct TRef<'a, T: GodotObject, Access: ThreadAccess = Shared> { /* fields omitted */ }

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

impl<'a, T: GodotObject, Access: ThreadAccess> TRef<'a, T, Access>[src]

pub fn as_ref(self) -> &'a T[src]

Returns the underlying reference without thread access.

pub fn cast<U>(self) -> Option<TRef<'a, U, Access>> where
    U: GodotObject + SubClass<T>, 
[src]

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

pub fn upcast<U>(&self) -> TRef<'a, U, Access> where
    U: GodotObject,
    T: SubClass<U>, 
[src]

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.

pub fn cast_instance<C>(self) -> Option<RefInstance<'a, C, Access>> where
    C: NativeClass<Base = T>, 
[src]

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

impl<'a, Kind, T, Access> TRef<'a, T, Access> where
    Kind: RefKind,
    T: GodotObject<RefKind = Kind>,
    Access: NonUniqueThreadAccess
[src]

pub fn claim(self) -> Ref<T, Access>[src]

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

This is only available for non-Unique accesses.

impl<'a, T: GodotObject> TRef<'a, T, Shared>[src]

pub unsafe fn try_from_instance_id(id: i64) -> Option<Self>[src]

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.

pub unsafe fn from_instance_id(id: i64) -> Self[src]

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

impl<'a, T, U> AsArg<U> for TRef<'a, T, Shared> where
    T: GodotObject + SubClass<U>,
    U: GodotObject
[src]

impl<'a, T: GodotObject, Access: ThreadAccess> AsRef<T> for TRef<'a, T, Access>[src]

impl<'a, T: GodotObject> AsVariant for TRef<'a, T, Shared>[src]

type Target = T

impl<'a, T: GodotObject, Access: ThreadAccess> Borrow<T> for TRef<'a, T, Access>[src]

impl<'a, T: GodotObject, Access: ThreadAccess> Clone for TRef<'a, T, Access>[src]

impl<'a, T: GodotObject, Access: ThreadAccess> Copy for TRef<'a, T, Access>[src]

impl<'a, T: GodotObject, Access: ThreadAccess> Debug for TRef<'a, T, Access>[src]

impl<'a, T: GodotObject, Access: ThreadAccess> Deref for TRef<'a, T, Access>[src]

type Target = T

The resulting type after dereferencing.

impl<'a, T, Access> OwnerArg<'a, T, Access> for TRef<'a, T, Access> where
    T: GodotObject,
    Access: ThreadAccess + 'static, 
[src]

impl<'a, T: GodotObject> ToVariant for TRef<'a, T, Shared>[src]

Auto Trait Implementations

impl<'a, T, Access> RefUnwindSafe for TRef<'a, T, Access> where
    Access: RefUnwindSafe,
    T: RefUnwindSafe
[src]

impl<'a, T, Access> Send for TRef<'a, T, Access> where
    Access: Send,
    T: Sync
[src]

impl<'a, T, Access> Sync for TRef<'a, T, Access> where
    Access: Sync,
    T: Sync
[src]

impl<'a, T, Access> Unpin for TRef<'a, T, Access> where
    Access: Unpin
[src]

impl<'a, T, Access> UnwindSafe for TRef<'a, T, Access> where
    Access: UnwindSafe,
    T: RefUnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> OwnedToVariant for T where
    T: ToVariant
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.