Skip to main content

plg_rt_atom_name

Function plg_rt_atom_name 

Source
#[unsafe(no_mangle)]
pub extern "C" fn plg_rt_atom_name(id: u32) -> u64
Expand description

Resolve an atom id to its name, packed (name_ptr << 32) | byte_len. The host reads len bytes at ptr to get the UTF-8 name. This reads the runtime interner, which holds program atoms AND query-introduced atoms (ids ≥ the compile-time table) — the static @plg_atom_strs table can’t resolve the latter. Returns 0 for an out-of-range id (defensive; should not occur — bson atom ids always come from this interner).

§Safety

Requires plg_init. The returned pointer is into the interner’s heap and is stable for the duration of host decode (the interner is only mutated during plg_rt_run_query, never between queries) — the host must read the bytes before the next query.