pub unsafe trait GarbageCollected {
// Required methods
fn trace(&self, visitor: &mut Visitor);
fn get_name(&self) -> &'static CStr;
}Expand description
Base trait for objects supporting garbage collection.
§Safety
implementors must guarantee that the trace()
method correctly visits all Member, WeakMember, and
[TraceReference] pointers held by this object. Failing to do so will leave
dangling pointers in the heap as objects are garbage collected.
Required Methods§
Sourcefn trace(&self, visitor: &mut Visitor)
fn trace(&self, visitor: &mut Visitor)
trace must call Visitor::trace for each
Member, WeakMember, or TracedReference reachable
from self.
Sourcefn get_name(&self) -> &'static CStr
fn get_name(&self) -> &'static CStr
Specifies a name for the garbage-collected object. Such names will never be hidden, as they are explicitly specified by the user of this API.
V8 may call this function while generating a heap snapshot or at other times. If V8 is currently generating a heap snapshot (according to HeapProfiler::IsTakingSnapshot), then the returned string must stay alive until the snapshot generation has completed. Otherwise, the returned string must stay alive forever. If you need a place to store a temporary string during snapshot generation, use HeapProfiler::CopyNameForHeapSnapshot.