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

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.

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

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

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

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

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

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.