pub struct TypeWalkVisitor { /* private fields */ }Expand description
The cxx extern "Rust" opaque the C++ type walk drives by calling its &mut self methods, each forwarding into the TypeWalkSink it was built over.
cxx generates a C++ class with a member function per method below; facade/typewalk_bridge.cpp receives a TypeWalkVisitor& and calls them. The visitor holds the sink as a lifetime-erased raw pointer: the walk_type_named/walk_type_ordinal/walk_func_type drivers are its only constructors, and each keeps the borrowed sink alive across the one synchronous walk, so the pointer is always valid and unaliased when a method reborrows it.
Implementations§
Source§impl TypeWalkVisitor
impl TypeWalkVisitor
Sourcepub unsafe fn from_raw(sink: *mut dyn TypeWalkSink) -> Self
pub unsafe fn from_raw(sink: *mut dyn TypeWalkSink) -> Self
Wrap a raw sink pointer as a TypeWalkVisitor for a walk driven outside this crate.
The self-contained walk_* drivers cover the standalone walks; this exists for the ctree
walk, where the visitor is handed to cfunc_walk_ctree alongside a CtreeVisitor
that shares the same builder. Passing sink as a raw pointer (not &mut) lets the
caller derive both from one provenance, so per-callback reborrows never conflict.
§Safety
sink must be non-null and point to a live TypeWalkSink that outlives every use of
the returned visitor, and stay unaliased for the duration of each callback (the walk is
single-threaded and non-reentrant).
§Panics
Panics if sink is null.