Skip to main content

RecursionState

This class manages the state of recursive validation processes by tracking a stack of identifiers and a global recursion depth. It is designed to prevent infinite loops and manage complexity during nested validation operations.

Attributes

AttributeTypeDescription
ids[RecursionStack](recursionstack.md?sid=recursion_guard_recursionstack)A stack of validator identifiers used to track the current path of execution and detect circular references.
depthu8A global counter representing the current nesting level across all validators to prevent stack overflow.

Constructor

Signature

def RecursionState(
ids: [RecursionStack](recursionstack.md?sid=recursion_guard_recursionstack),
depth: u8
) - > [RecursionState](recursionstate.md?sid=recursion_guard_recursionstate)

Parameters

NameTypeDescription
ids[RecursionStack](recursionstack.md?sid=recursion_guard_recursionstack)The stack used to track recursion identifiers.
depthu8The current depth of the recursion.

Signature

@staticmethod
def new() - > [RecursionState](recursionstate.md?sid=recursion_guard_recursionstate)

Methods


incr_depth()

def incr_depth() - > null

Increments the current recursion depth counter.

Returns

TypeDescription
null

decr_depth()

def decr_depth() - > null

Decrements the current recursion depth counter.

Returns

TypeDescription
null

get_depth()

def get_depth() - > u8

Retrieves the current total recursion depth across all validators.

Returns

TypeDescription
u8The current depth level as an unsigned 8-bit integer.