pub struct TInstance<'a, T: NativeClass, Own: Ownership = Shared> { /* private fields */ }
Expand description

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§

source§

impl<'a, T: NativeClass, Own: Ownership> TInstance<'a, T, Own>

source

pub fn base(&self) -> TRef<'a, T::Base, Own>

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

source

pub fn script(&self) -> &T::UserData

Returns a reference to the script wrapper.

source

pub fn try_from_base(owner: TRef<'a, T::Base, Own>) -> Option<Self>

Try to downcast TRef<'a, T::Base, Own> to TInstance<T>.

source§

impl<'a, T: NativeClass, Own: NonUniqueOwnership> TInstance<'a, T, Own>

source

pub fn claim(self) -> Instance<T, Own>

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

This is only available for non-Unique accesses.

source§

impl<'a, T: NativeClass, Own: Ownership> TInstance<'a, T, Own>where
    T::Base: GodotObject,

Methods for instances with reference-counted base classes.

source

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

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

source

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

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

source

pub fn map_owned<F, U>(&self, op: F) -> Result<U, <T::UserData as MapOwned>::Err>where
    T::UserData: MapOwned,
    F: FnOnce(T, TRef<'_, T::Base, Own>) -> U,

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

Trait Implementations§

source§

impl<'a, T, Own: Ownership> Clone for TInstance<'a, T, Own>where
    T: NativeClass,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a, T: Debug + NativeClass, Own: Debug + Ownership> Debug for TInstance<'a, T, Own>where
    T::Base: Debug,
    T::UserData: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a, T, U> AsArg<U> for TInstance<'a, T, Shared>where
    T: NativeClass,
    T::Base: GodotObject + SubClass<U>,
    T::UserData: Map,
    U: GodotObject,

Auto Trait Implementations§

§

impl<'a, T, Own> RefUnwindSafe for TInstance<'a, T, Own>where
    Own: RefUnwindSafe,
    <T as NativeClass>::Base: RefUnwindSafe,
    <T as NativeClass>::UserData: RefUnwindSafe,

§

impl<'a, T, Own> Send for TInstance<'a, T, Own>where
    Own: Send,
    <T as NativeClass>::Base: Sync,
    <T as NativeClass>::UserData: Send,

§

impl<'a, T, Own> Sync for TInstance<'a, T, Own>where
    Own: Sync,
    <T as NativeClass>::Base: Sync,
    <T as NativeClass>::UserData: Sync,

§

impl<'a, T, Own> Unpin for TInstance<'a, T, Own>where
    Own: Unpin,
    <T as NativeClass>::UserData: Unpin,

§

impl<'a, T, Own> UnwindSafe for TInstance<'a, T, Own>where
    Own: UnwindSafe,
    <T as NativeClass>::Base: RefUnwindSafe,
    <T as NativeClass>::UserData: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere
    T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere
    T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere
    U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere
    T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere
    U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere
    U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.