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
| Attribute | Type | Description |
|---|---|---|
| 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. |
| depth | u8 | A 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
| Name | Type | Description |
|---|---|---|
| ids | [RecursionStack](recursionstack.md?sid=recursion_guard_recursionstack) | The stack used to track recursion identifiers. |
| depth | u8 | The 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
| Type | Description |
|---|---|
null |
decr_depth()
def decr_depth() - > null
Decrements the current recursion depth counter.
Returns
| Type | Description |
|---|---|
null |
get_depth()
def get_depth() - > u8
Retrieves the current total recursion depth across all validators.
Returns
| Type | Description |
|---|---|
u8 | The current depth level as an unsigned 8-bit integer. |