qubit_json/value/traverse/json_tree_control.rs
1// =============================================================================
2// Copyright (c) 2026 Haixing Hu.
3//
4// SPDX-License-Identifier: Apache-2.0
5//
6// Licensed under the Apache License, Version 2.0.
7// =============================================================================
8//! Defines control returned by mutable JSON tree visitors.
9
10/// Selects whether a mutable tree visitor receives callbacks for descendants.
11///
12/// This control is returned by [`super::JsonTreeMutVisitor`] and interpreted by
13/// [`super::JsonTreeMutator::process`]. Reader APIs do not return this control.
14///
15/// # Examples
16///
17/// ```
18/// use qubit_json::value::traverse::JsonTreeControl;
19///
20/// let control = JsonTreeControl::SkipSubtree;
21/// assert_eq!(control, JsonTreeControl::SkipSubtree);
22/// ```
23#[must_use = "the traversal control determines whether descendant callbacks run"]
24#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
25pub enum JsonTreeControl {
26 /// Visit the node's descendants in normal depth-first order.
27 Descend,
28 /// Skip callbacks for the node's descendants.
29 ///
30 /// Descendants remain subject to complete input and final output budget
31 /// accounting performed by [`super::JsonTreeMutator::process`].
32 SkipSubtree,
33}