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>

source

pub fn new() -> Option<Self>

Creates a new reference to the class.

source

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.

source

pub unsafe fn fields(&self) -> Option<&T>

Returns a reference to the fields of the class.

§Safety

The underlying value can be accessed mutably at any point through another copy of the Ref. Ideally, the caller should ensure that the returned reference is short-lived.

source

pub unsafe fn fields_mut(&mut self) -> Option<&mut T>

Returns a mutable reference to the fields of the class.

§Safety

The underlying value can be accessed mutably at any point through another copy of the Ref. Ideally, the caller should ensure that the returned reference is short-lived.

source

pub unsafe fn instance( &self, ) -> Option<&<<T as ScriptClass>::Kind as ClassKind<T>>::NativeType>

Returns a reference to the instance of the class.

§Safety

The underlying value can be accessed mutably at any point through another copy of the Ref. Ideally, the caller should ensure that the returned reference is short-lived.

source

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.

source

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.

source

pub fn is_null(&self) -> bool

Returns whether the reference is null.

source

pub fn is_exactly_a<U>(&self) -> bool
where U: ScriptClass,

source

pub fn is_a<U>(&self) -> bool
where U: ScriptClass,

Trait Implementations§

source§

impl<T: ScriptClass> Clone for Ref<T>

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<T: ScriptClass> Default for Ref<T>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T: ScriptClass> Drop for Ref<T>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<A: ScriptClass> NativeRepr for Ref<A>

source§

const NAME: &'static str = _

source§

impl<T: ScriptClass> AsReceiver for &Ref<T>

source§

impl<T: ScriptClass> AsReceiver for Ref<T>

source§

impl<T: ScriptClass> Send for Ref<T>

source§

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>
where <<T as ScriptClass>::Kind as ClassKind<T>>::NativeType: Unpin,

§

impl<T> UnwindSafe for Ref<T>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<A> FromRepr for A
where A: NativeRepr,

§

type Repr = A

source§

fn from_repr(repr: <A as FromRepr>::Repr) -> A

source§

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

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<A> IntoRepr for A
where A: NativeRepr,

§

type Repr = A

source§

fn into_repr(self) -> <A as IntoRepr>::Repr

source§

impl<T> ToOwned for T
where 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 T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.