Skip to main content

Pinned

Struct Pinned 

Source
pub struct Pinned<T: UeClass> { /* private fields */ }
Expand description

An owning GC root for a UObject.

  • !Copy, !Clone — unique ownership of the GC root.
  • Send — can be moved across threads.
  • !Sync — must only be used on the game thread.
  • Drop removes the GC root and unregisters from destroy notification.

Method calls on Pinned<T> use a local alive flag (~1-3 cycles) instead of an FFI is_valid call (~15-30 cycles) for validity checking.

Implementations§

Source§

impl<T: UeClass> Pinned<T>

Source

pub fn new(obj: UObjectRef<T>) -> UikaResult<Self>

Pin an object by adding a GC root and registering for destroy notification. Fails if the object is already destroyed.

Source

pub fn is_alive(&self) -> bool

Check whether the pinned object is still alive (local memory read).

Source

pub fn handle(&self) -> UObjectHandle

Get the underlying raw handle. Guaranteed valid while this Pinned exists and is_alive() returns true.

Source

pub fn as_ref(&self) -> UObjectRef<T>

Borrow as a lightweight UObjectRef. The returned ref is valid as long as this Pinned is alive.

Source

pub fn as_checked(&self) -> Checked<T>

Create a Checked<T> handle from this pinned reference. Valid as long as is_alive() returns true (debug-asserted).

Trait Implementations§

Source§

impl<T: UeClass> Debug for Pinned<T>

Source§

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

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

impl<T: UeClass> Drop for Pinned<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T: UeClass> UeHandle for Pinned<T>

Source§

fn checked_handle(&self) -> UikaResult<UObjectHandle>

Return the raw handle if the object is alive, or Err(ObjectDestroyed).
Source§

fn raw_handle(&self) -> UObjectHandle

Return the raw handle without validity check.
Source§

impl<T: UeClass> ValidHandle for Pinned<T>

Source§

fn handle(&self) -> UObjectHandle

Return the raw handle. The implementor guarantees (or debug-asserts) that the handle is valid.
Source§

impl<T: UeClass> Send for Pinned<T>

Auto Trait Implementations§

§

impl<T> Freeze for Pinned<T>

§

impl<T> RefUnwindSafe for Pinned<T>
where T: RefUnwindSafe,

§

impl<T> !Sync for Pinned<T>

§

impl<T> Unpin for Pinned<T>

§

impl<T> UnsafeUnpin for Pinned<T>

§

impl<T> UnwindSafe for Pinned<T>
where T: RefUnwindSafe,

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

Source§

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>,

Source§

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.