pub struct CtreeVisitor { /* private fields */ }Expand description
The cxx extern "Rust" opaque the C++ ctree walk drives by calling its &mut self methods, each forwarding into the CtreeSink it was built over.
cxx generates a C++ class with a member function per method below; facade/ctree_bridge.cpp receives a CtreeVisitor& and calls them. The visitor holds the sink as a lifetime-erased raw pointer: CtreeVisitor::from_raw is its only constructor, and the caller 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 CtreeVisitor
impl CtreeVisitor
Sourcepub unsafe fn from_raw(sink: *mut dyn CtreeSink) -> Self
pub unsafe fn from_raw(sink: *mut dyn CtreeSink) -> Self
Wrap a raw sink pointer as a CtreeVisitor for a walk driven by cfunc_walk_ctree.
Passing sink as a raw pointer (not &mut) lets the caller derive both it and any node
context it aliases (e.g. a shared builder) from one provenance, so per-callback reborrows
never conflict.
§Safety
sink must be non-null and point to a live CtreeSink 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.