Skip to main content

UserdataPayload

Enum UserdataPayload 

Source
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.1 newproxy() 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 'static non-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

§type_id: TypeId

TypeId of the host value, used as the downcast key.

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

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