Struct gdnative::prelude::RefInstance[][src]

pub struct RefInstance<'a, T, Access> where
    Access: ThreadAccess,
    T: NativeClass
{ /* fields omitted */ }

A reference to a GodotObject with a rust NativeClass attached that is assumed safe during a certain lifetime.

See the type-level documentation on Ref for more information on typed thread accesses.

Implementations

impl<'a, T, Access> RefInstance<'a, T, Access> where
    Access: ThreadAccess,
    T: NativeClass
[src]

pub fn base(&self) -> TRef<'a, <T as NativeClass>::Base, Access>[src]

Returns a reference to the base object with the same lifetime.

pub fn script(&self) -> &<T as NativeClass>::UserData[src]

Returns a reference to the script wrapper.

pub fn try_from_base(
    owner: TRef<'a, <T as NativeClass>::Base, Access>
) -> Option<RefInstance<'a, T, Access>>
[src]

Try to downcast TRef<'a, T::Base, Access> to RefInstance<T>.

impl<'a, T, Access> RefInstance<'a, T, Access> where
    Access: NonUniqueThreadAccess,
    T: NativeClass
[src]

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

Persists this into a persistent Instance with the same thread access, without cloning the userdata wrapper.

This is only available for non-Unique accesses.

impl<'a, T, Access> RefInstance<'a, T, Access> where
    Access: ThreadAccess,
    T: NativeClass,
    <T as NativeClass>::Base: GodotObject
[src]

Methods for instances with reference-counted base classes.

pub fn map<F, U>(
    &self,
    op: F
) -> Result<U, <<T as NativeClass>::UserData as Map>::Err> where
    F: FnOnce(&T, TRef<'_, <T as NativeClass>::Base, Access>) -> U,
    <T as NativeClass>::UserData: Map
[src]

Calls a function with a NativeClass instance and its owner, and returns its return value.

pub fn map_mut<F, U>(
    &self,
    op: F
) -> Result<U, <<T as NativeClass>::UserData as MapMut>::Err> where
    F: FnOnce(&mut T, TRef<'_, <T as NativeClass>::Base, Access>) -> U,
    <T as NativeClass>::UserData: MapMut
[src]

Calls a function with a NativeClass instance and its owner, and returns its return value.

Trait Implementations

impl<'a, T, Access> Clone for RefInstance<'a, T, Access> where
    Access: ThreadAccess,
    T: NativeClass
[src]

impl<'a, T, Access> Debug for RefInstance<'a, T, Access> where
    Access: ThreadAccess + Debug,
    T: NativeClass + Debug,
    <T as NativeClass>::Base: Debug,
    <T as NativeClass>::UserData: Debug
[src]

Auto Trait Implementations

impl<'a, T, Access> RefUnwindSafe for RefInstance<'a, T, Access> where
    Access: RefUnwindSafe,
    <T as NativeClass>::Base: RefUnwindSafe,
    <T as NativeClass>::UserData: RefUnwindSafe
[src]

impl<'a, T, Access> Send for RefInstance<'a, T, Access> where
    Access: Send,
    <T as NativeClass>::Base: Sync,
    <T as NativeClass>::UserData: Send
[src]

impl<'a, T, Access> Sync for RefInstance<'a, T, Access> where
    Access: Sync,
    <T as NativeClass>::Base: Sync,
    <T as NativeClass>::UserData: Sync
[src]

impl<'a, T, Access> Unpin for RefInstance<'a, T, Access> where
    Access: Unpin,
    <T as NativeClass>::UserData: Unpin
[src]

impl<'a, T, Access> UnwindSafe for RefInstance<'a, T, Access> where
    Access: UnwindSafe,
    <T as NativeClass>::Base: RefUnwindSafe,
    <T as NativeClass>::UserData: UnwindSafe
[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> 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.