Expand description
Native Rust structural visiting.
Two public layers:
Dispatcher+structural_visit— handlers drive recursion through an explicitStructuralVisitorViewcontext. Pass state belongs on the dispatcher;visitor.visit(self, &child)reborrows it for recursive calls. Unmatched values use default child traversal.structural_walk— dispatcher or closure observers steer engine-owned recursion throughWalkResult(advance, skip, interrupt).
Both layers thread definition-region state explicitly. Walk handlers opt in
with a trailing DefRegionKind; visit handlers read it from their context
and may override it for a child through StructuralVisitorView::with_def_region_kind.
§Safety of the implementation
The public interface is safe; its implementation deliberately uses raw pointers. Each private runtime has a matching dispatcher vtable and a fixed dispatcher identity. The dispatcher stays alive in the outer call, and the engine’s dispatcher pointer publishes the actual exclusive reborrow before native recursion, then restores the enclosing borrow on return. Views and native runtime handles cannot escape their synchronous calls. No reference to the whole runtime spans recursion, and owning ABI results transfer exactly one reference at each boundary.
Callbacks must return failures through Result and must not panic. A panic
reaching the non-unwinding extern "C" callback boundary aborts the process;
visitor callbacks do not catch or transport panic payloads across native frames.
Structs§
- Structural
Visit Engine - Scoped Rust visitor runtime with a statically selected native base.
- Structural
Visitor Obj - The native visitor state, laid out as the prefix of the C++
StructuralVisitorObj. - Structural
Visitor View - The running structural visit, passed to each handler.
- Visit
Interrupt - Interrupt state of a traversal, an
ffi.VisitInterruptobject. - Visit
Interrupt Obj - Native
ffi.VisitInterruptobject containing the interruption payload.
Enums§
- DefRegion
Kind - Definition-region state active at the current value.
Traits§
- Structural
Visitor Base - Native state and default traversal for
StructuralVisitEngine. The engine owns allocation, scoped dispatch and results.
Functions§
- structural_
visit - Visit
rootwith an owned or borrowedDispatcher.