Skip to main content

qubit_json/value/traverse/
json_tree_context.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 context supplied with one JSON tree callback.
9
10use super::JsonTreeLocation;
11
12/// Describes the root-inclusive depth and parent location of a JSON node.
13///
14/// # Examples
15///
16/// ```
17/// use qubit_json::value::traverse::JsonTreeContext;
18/// use qubit_json::value::traverse::JsonTreeLocation;
19///
20/// let context = JsonTreeContext {
21///     depth: 1,
22///     location: JsonTreeLocation::Root,
23/// };
24/// assert_eq!(context.depth, 1);
25/// ```
26#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
27pub struct JsonTreeContext<'a> {
28    /// Root-inclusive depth; the root is always at depth one.
29    pub depth: usize,
30    /// Location of this node in its immediate parent.
31    pub location: JsonTreeLocation<'a>,
32}