Skip to main content

CtreeVisitor

Struct CtreeVisitor 

Source
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

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.