Expand description
Reference-counted interface objects: the producer half of the ABI’s object model.
An interface value crosses the C ABI as a {tag}* that is really an
Arc<T> turned into a raw pointer with Arc::into_raw. The count
lives inside the producer’s allocation, so every consumer wrapper, every
value buffer holding an object token, and every in-flight async call can
own its own strong reference: {tag}_clone bumps the count and
{tag}_destroy releases one reference. The object is dropped when the last
reference goes.
The #[weaveffi::module] expansion calls these helpers from its generated
thunks; producers never touch them directly. They exist so every unsafe
pointer-to-Arc conversion has one audited home.
Functions§
- lower_
object - Hand one strong reference to the consumer.
- lower_
object_ opt - Lower an optional object:
Nonebecomes null,Sometransfers one strong reference exactly likelower_object. - object_
arc ⚠ - Take a new strong reference to a borrowed object, so the producer can
retain it past the call. Null yields
None. - object_
clone ⚠ - The body of every
{tag}_clonesymbol: return a new strong reference to the same object. The pointer value is unchanged; null is a no-op returning null. - object_
destroy ⚠ - The body of every
{tag}_destroysymbol: release one strong reference. The object is dropped when the last reference goes. Null is a no-op, and a panickingDropis swallowed because a destructor has noout_errslot and must never unwind into C. - object_
from_ ⚠token - Adopt the strong reference carried by an object token read from a value
buffer. A zero token is a contract violation and yields
None. - object_
ref ⚠ - Borrow an object for the duration of a call without touching its count.
Null yields
None. - object_
to_ token - The object token an interface value takes inside a value buffer: the
lower_objectpointer widened tou64. The token carries one strong reference; whoever decodes it adopts that reference.