pub enum UserdataPayload {
File(FileHandle),
Empty,
Host {
type_id: TypeId,
data: Box<dyn Any + 'static>,
trace_fn: Option<fn(&(dyn Any + 'static), &mut UserdataMarker<'_>)>,
},
}Expand description
A userdata’s host-side payload. Beyond io file handles luna exposes:
Empty— PUC 5.1newproxy()carries only identity + an optional metatable hook for__index/__newindex/__gc.Host— embedder-supplied Rust value (v1.1 B8). The host owns the value; luna treats it as opaque Any. v1.1 restricts host types to'staticnon-GC-bearing types; Trace-bearing host payloads land in Phase 4+ alongside the userdata GC ripple.
Variants§
File(FileHandle)
an io stream/file handle
Empty
a PUC 5.1 newproxy userdata — no host payload, only identity
Host
B8 — embedder-supplied Rust value. type_id keys the downcast;
data is the boxed payload.
Fields
data: Box<dyn Any + 'static>Boxed host payload (the embedder owns the underlying data
semantically; luna treats it as opaque Any).
trace_fn: Option<fn(&(dyn Any + 'static), &mut UserdataMarker<'_>)>Trace adapter for the concrete T keyed by type_id.
Captured by crate::vm::Vm::create_userdata as a monomorphic
fn(&dyn Any, &mut UserdataMarker) whose body downcasts the
payload to &T and calls crate::vm::LuaUserdata::trace.
None means “no trace adapter wired” — only possible for
payloads constructed via the v1.1 crate::runtime::heap::Heap::new_userdata
path that bypasses the trait sugar (none exist in luna today,
but the Option preserves source-compat for any external
crate that built a UserdataPayload::Host literal under the
v1.2 shape).
Phase TB (v1.3) — see .dev/rfcs/v1.3-audit-trace-bearing-userdata.md.