Struct red4ext_rs::types::Ref
source · pub struct Ref<T: ScriptClass>(/* private fields */);
Expand description
A reference counted shared pointer to a script class.
Implementations§
source§impl<T: ScriptClass> Ref<T>
impl<T: ScriptClass> Ref<T>
sourcepub fn new_with(init: impl FnOnce(&mut T)) -> Option<Self>
pub fn new_with(init: impl FnOnce(&mut T)) -> Option<Self>
Creates a new reference to the class and initializes it with the provided function.
sourcepub unsafe fn fields_mut(&mut self) -> Option<&mut T>
pub unsafe fn fields_mut(&mut self) -> Option<&mut T>
sourcepub unsafe fn instance(
&self,
) -> Option<&<<T as ScriptClass>::Kind as ClassKind<T>>::NativeType>
pub unsafe fn instance( &self, ) -> Option<&<<T as ScriptClass>::Kind as ClassKind<T>>::NativeType>
sourcepub fn downgrade(self) -> WeakRef<T>
pub fn downgrade(self) -> WeakRef<T>
Converts the reference to a WeakRef
. This will decrement the strong reference count
and increment the weak reference count.
sourcepub fn cast<U>(self) -> Option<Ref<U>>where
U: ScriptClass,
pub fn cast<U>(self) -> Option<Ref<U>>where
U: ScriptClass,
Attempts to cast the reference to a reference of another class.
Returns None
if the target class is not compatible.
pub fn is_exactly_a<U>(&self) -> boolwhere
U: ScriptClass,
pub fn is_a<U>(&self) -> boolwhere
U: ScriptClass,
Trait Implementations§
source§impl<T: ScriptClass> Clone for Ref<T>
impl<T: ScriptClass> Clone for Ref<T>
source§impl<T: ScriptClass> Default for Ref<T>
impl<T: ScriptClass> Default for Ref<T>
source§impl<T: ScriptClass> Drop for Ref<T>
impl<T: ScriptClass> Drop for Ref<T>
source§impl<A: ScriptClass> NativeRepr for Ref<A>
impl<A: ScriptClass> NativeRepr for Ref<A>
impl<T: ScriptClass> AsReceiver for &Ref<T>
impl<T: ScriptClass> AsReceiver for Ref<T>
impl<T: ScriptClass> Send for Ref<T>
impl<T: ScriptClass> Sync for Ref<T>
Auto Trait Implementations§
impl<T> Freeze for Ref<T>
impl<T> !RefUnwindSafe for Ref<T>
impl<T> Unpin for Ref<T>
impl<T> UnwindSafe for Ref<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more