Skip to main content

HashMapValueElem

Trait HashMapValueElem 

Source
pub unsafe trait HashMapValueElem {
    // Required methods
    unsafe fn release_typed_array(ptr: *mut TypedArray<Self>)
       where Self: Sized;
    unsafe fn share_clone(elem: &Self) -> Self
       where Self: Sized;
    unsafe fn release_owned(value: Self)
       where Self: Sized;
}
Expand description

Per-V dispatcher trait for HashMapData<V>::Drop — releases the value buffer (*mut TypedArray<V>) at refcount-0 of the enclosing Arc<HashMapData<V>>.

Authority: ADR-006 §2.7.24 Q25.B SUPERSEDED + bulldozer-wave-1-inventory.md §C.4 option (a.2). The trait dispatches per-V release at compile time via the Rust type system — no runtime NativeKind probe, no is_heap() probe, no Bool-default fallback. Mirror of v2::heap_element::HeapElement shape, but operates on the OUTER TypedArray<V> allocation rather than on individual heap-element pointers.

Impls partition V into:

  • POD scalar Vs (i64, f64, u8 for Bool): TypedArray::<V>::drop_array frees the data buffer + the struct; no per-element work.
  • HeapHeader-equipped raw pointers (*const StringObj, *const DecimalObj): TypedArray::<*const T>::drop_array_heap walks the data buffer and calls T::release_elem per element, then frees the struct. Requires T: v2::heap_element::HeapElement.
  • #[repr(transparent)] newtype-as-element shapes (TypedObjectPtr, TraitObjectPtr): manual walk that ptr::reads each element to invoke its Drop (which retires the v2-raw refcount share via release_elem on the inner *const TypedObjectStorage / *const TraitObjectStorage).

Char (char codepoint) is reachable per §C.5 dead-but-derived disposition — included as a POD-scalar V.

§Safety

Implementors must guarantee:

  1. release_typed_array(ptr) is sound when ptr points to a live TypedArray<Self> allocation produced by TypedArray::<Self>::new / with_capacity / from_slice.
  2. After this call, ptr is invalid; the data buffer + struct are freed.
  3. Per-element ownership semantics match the storage contract — POD elements need no per-element release; HeapHeader-equipped elements have their shares retired before the data buffer is freed.

Required Methods§

Source

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

Release a *mut TypedArray<Self> allocation: retire per-element shares (where applicable) + free the data buffer + free the struct.

§Safety

ptr must point to a valid, live TypedArray<Self> allocated by the v2-raw TypedArray::<Self> allocator (new, with_capacity, from_slice). After this call returns, ptr is invalid.

Source

unsafe fn share_clone(elem: &Self) -> Self
where Self: Sized,

Clone a single element with proper refcount-share semantics.

  • POD scalar Vs (i64/f64/u8/char): byte copy — no refcount work.
  • HeapHeader-equipped raw pointers (*const StringObj/*const DecimalObj): pointer copy + v2_retain on the pointed-to HeapHeader.
  • #[repr(transparent)] ptr-newtypes (TypedObjectPtr/TraitObjectPtr): delegate to the wrapper’s Clone impl (which does v2_retain).

Wave 2 Round 3b C2-joint ckpt-3 (2026-05-14): added to support the per-V mutation API (insert / merge / get_share) on HashMapData<V>. Per ADR-006 §2.7.24 Q25.B SUPERSEDED + audit §C.4.

§Safety

elem must reference a live element of a TypedArray<Self> (or a freshly-allocated element owned by the caller). The implementor must produce a new owned share — for HeapElement / ptr-newtype V this bumps the refcount on the pointed-to allocation; for POD V it is a trivial copy.

Source

unsafe fn release_owned(value: Self)
where Self: Sized,

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.

Wave 2 Round 3b C2-joint ckpt-3 (2026-05-14): added for the per-V mutation API’s overwrite path (insert when key already present — the old value’s share must be retired before the slot is overwritten).

§Safety

value must be a valid owned V — for HeapElement / ptr-newtype V types the caller transfers one refcount share to this method, which retires it.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl HashMapValueElem for char

Source§

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

Char codepoint (4 bytes / element). Dead-but-derived per §C.5; included for forward-cleanliness with the HeapValue::Char xml/json marshal path.

Source§

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

Source§

unsafe fn release_owned(_value: Self)

Source§

impl HashMapValueElem for f64

Source§

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

Source§

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

Source§

unsafe fn release_owned(_value: Self)

Source§

impl HashMapValueElem for i64

Source§

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

Source§

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

Source§

unsafe fn release_owned(_value: Self)

Source§

impl HashMapValueElem for *const DecimalObj

Source§

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

Source§

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

Source§

unsafe fn release_owned(value: Self)

Source§

impl HashMapValueElem for *const StringObj

Source§

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

Source§

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

Source§

unsafe fn release_owned(value: Self)

Source§

impl HashMapValueElem for u8

Source§

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

Used as the Bool V (one byte per element).

Source§

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

Source§

unsafe fn release_owned(_value: Self)

Implementors§