Skip to main content

TraitObjectPtr

Struct TraitObjectPtr 

Source
#[repr(transparent)]
pub struct TraitObjectPtr(pub *const TraitObjectStorage);
Expand description

Owning newtype around *const TraitObjectStorage carrying one v2-raw refcount share on the pointed-to allocation’s HeapHeader.

Wave 2 Round 4 D4 ckpt-final-prime² (2026-05-14): mirrors the TypedObjectPtr precedent (above) for TraitObjectStorage. Carrier shape used as both:

  • HeapValue::TraitObject(TraitObjectPtr) variant payload
  • Future TypedArrayData::TraitObject element type (if/when the §Q25.A monomorphic specialization for trait-object-element arrays lands; not under this ckpt’s scope)

#[repr(transparent)] so the in-memory layout is identical to *const TraitObjectStorage — zero ABI cost vs the raw pointer; the wrapper exists only to localize the manual Send/Sync impl + the Drop/Clone refcount discipline. Same auto-trait suppression rule applies as for TypedObjectPtr — per-T newtype is the canonical workaround for raw-ptr inner elements in HeapValue variant payloads without disabling Rust’s auto-derived Send/Sync/Clone/Drop on the enclosing HeapValue enum.

Construction-side contract: callers transfer one strong-count share on the v2-raw HeapHeader (initialized to 1 via TraitObjectStorage::_new) to the new TraitObjectPtr. Reads via as_ptr() return the underlying pointer without bumping refcount.

Tuple Fields§

§0: *const TraitObjectStorage

Implementations§

Source§

impl TraitObjectPtr

Source

pub fn new(ptr: *const TraitObjectStorage) -> Self

Construct from a raw pointer obtained via TraitObjectStorage::_new. The caller transfers one strong-count share to the wrapper.

Source

pub fn as_ptr(&self) -> *const TraitObjectStorage

Recover the underlying raw pointer. Does NOT bump refcount; the returned pointer is borrowed for the wrapper’s lifetime.

Source

pub fn is_null(&self) -> bool

Whether the pointer is null.

Source

pub fn into_raw(self) -> *const TraitObjectStorage

Consume the wrapper without running Drop, returning the raw pointer. The caller takes over the one refcount share. Mirror of Arc::into_raw.

Methods from Deref<Target = TraitObjectStorage>§

Source

pub fn method(&self, name: &str) -> Option<&VTableEntry>

Convenience: look up a method by name in the vtable. Returns None for an unknown method (the dispatch tier surfaces this as a runtime error — under universal-dyn there is no compile- time ETO-002 for “method not in trait” since the trait’s declared method set is the surface checked at compile time; runtime lookup failures indicate a vtable-construction bug).

Source

pub fn vtable_eq(&self, other: &Self) -> bool

Identity check for the §Q25.C.2 Self-arg runtime contract. Arc::ptr_eq on vtable Arcs is the tightest comparison; both TraitObjectStorage instances must share the same vtable allocation (which happens when both came from the same (impl Trait for Type) pair).

Trait Implementations§

Source§

impl Clone for TraitObjectPtr

Source§

fn clone(&self) -> Self

v2-raw refcount bump via v2_retain on the pointed-to HeapHeader. The clone owns its own share, retired at its own Drop.

1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for TraitObjectPtr

Source§

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

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

impl Default for TraitObjectPtr

Source§

fn default() -> Self

Null pointer default — used by container types that need a Default impl. Callers must not dereference a default-constructed TraitObjectPtr. No refcount share is owed; Drop on a null pointer is a no-op.

Source§

impl Deref for TraitObjectPtr

Source§

type Target = TraitObjectStorage

The resulting type after dereferencing.
Source§

fn deref(&self) -> &TraitObjectStorage

Dereferences the value.
Source§

impl Drop for TraitObjectPtr

Source§

fn drop(&mut self)

Retire the owned share via TraitObjectStorage::release_elem (HeapElement trait — calls v2_release and, on refcount=0, runs _drop to dealloc the allocation + retire inner shares). No-op on null wrappers.

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Hash for TraitObjectPtr

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl HashMapValueElem for TraitObjectPtr

Source§

unsafe fn release_typed_array(ptr: *mut TypedArray<Self>)

Mirror of the TypedObjectPtr impl above; per-element Drop runs release_elem on *const TraitObjectStorage.

Source§

unsafe fn share_clone(elem: &Self) -> Self

Clone a single element with proper refcount-share semantics. Read more
Source§

unsafe fn release_owned(_value: Self)

Release a single owned value (one refcount share). For POD V it is a no-op (byte copy falls out of scope). For HeapElement V the share is retired via release_elem on the pointer. For Ptr-newtype V the wrapper’s Drop runs automatically when the value drops. Read more
Source§

impl PartialEq for TraitObjectPtr

Source§

fn eq(&self, other: &TraitObjectPtr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for TraitObjectPtr

Source§

impl Send for TraitObjectPtr

Source§

impl StructuralPartialEq for TraitObjectPtr

Source§

impl Sync for TraitObjectPtr

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

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.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,