Struct gdnative_core::object::TRef [−][src]
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]
U: GodotObject + SubClass<T>,
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]
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.
pub fn cast_instance<C>(self) -> Option<RefInstance<'a, C, Access>> where
C: NativeClass<Base = T>, [src]
C: NativeClass<Base = T>,
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]
Kind: RefKind,
T: GodotObject<RefKind = Kind>,
Access: NonUniqueThreadAccess,
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]
T: GodotObject + SubClass<U>,
U: GodotObject,
fn as_arg_ptr(&self) -> *mut godot_object[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]
fn clone(&self) -> Self[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[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]
impl<'a, T, Access> OwnerArg<'a, T, Access> for TRef<'a, T, Access> where
T: GodotObject,
Access: ThreadAccess + 'static, [src]
T: GodotObject,
Access: ThreadAccess + 'static,
fn from_safe_ref(owner: TRef<'a, T, Access>) -> Self[src]
impl<'a, T: GodotObject> ToVariant for TRef<'a, T, Shared>[src]
fn to_variant(&self) -> Variant[src]
Auto Trait Implementations
impl<'a, T, Access> RefUnwindSafe for TRef<'a, T, Access> where
Access: RefUnwindSafe,
T: RefUnwindSafe, [src]
Access: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, Access> Send for TRef<'a, T, Access> where
Access: Send,
T: Sync, [src]
Access: Send,
T: Sync,
impl<'a, T, Access> Sync for TRef<'a, T, Access> where
Access: Sync,
T: Sync, [src]
Access: Sync,
T: Sync,
impl<'a, T, Access> Unpin for TRef<'a, T, Access> where
Access: Unpin, [src]
Access: Unpin,
impl<'a, T, Access> UnwindSafe for TRef<'a, T, Access> where
Access: UnwindSafe,
T: RefUnwindSafe, [src]
Access: UnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> OwnedToVariant for T where
T: ToVariant, [src]
T: ToVariant,
pub fn owned_to_variant(Self) -> Variant[src]
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,