pub struct CallTree(/* private fields */);Expand description
A cursor-based tree structure for tracking hierarchical contract calls.
The tree maintains a “current position” pointer that moves through the tree as contracts call each other and return. The internal pointer represents:
None: Empty tree (no calls have been made)Some(node): Points to the currently executing contract call
§Memory Management
Uses raw pointers with manual allocation (Box::leak) and deallocation
(free_tree). The Drop implementation ensures proper cleanup.
Implementations§
Source§impl CallTree
impl CallTree
Sourcepub fn iter(&self) -> impl Iterator<Item = &CallTreeElem>
pub fn iter(&self) -> impl Iterator<Item = &CallTreeElem>
Returns an iterator over the current node and its descendants.
Traverses in reverse post-order (rightmost leaf first): deepest-rightmost children first, then left siblings, then parents. This matches how contract calls unwind (deepest calls complete first).
§Example
Notation:
->means “calls”[]groups sibling calls (sequential calls made by the same contract),separates siblings (calls made one after another)
For tree A -> B -> [D, E] and A -> C, if positioned at A:
A calls B, which calls D then E, then A calls C.
Tree structure:
A
/ \
B C
/ \
D EIterator yields: C, E, D, B, A (rightmost leaves first)
For tree where TC calls A, which makes two sequential calls to TC and D:
- TC means “Transfer contract”
- A means “Alice contract”
- B means “Bob contract”
- C means “Charlie contract”
- D means “David contract”
Tree structure:
TC (root)
|
A
/ \
TC D
/
CCall sequence: TC -> [A -> [TC -> C], D]
- TC calls A
- A calls TC (which calls C), then A calls D
- TC and D are siblings (both called by A sequentially)
Iterator at root TC yields: D, C, TC (from A), A, TC (root) Iterator at A yields: D, C, TC, A
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CallTree
impl RefUnwindSafe for CallTree
impl !Send for CallTree
impl !Sync for CallTree
impl Unpin for CallTree
impl UnsafeUnpin for CallTree
impl UnwindSafe for CallTree
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more