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, JsonTreeLocation};
18///
19/// let context = JsonTreeContext {
20///     depth: 1,
21///     location: JsonTreeLocation::Root,
22/// };
23/// assert_eq!(context.depth, 1);
24/// ```
25#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
26pub struct JsonTreeContext<'a> {
27    /// Root-inclusive depth; the root is always at depth one.
28    pub depth: usize,
29    /// Location of this node in its immediate parent.
30    pub location: JsonTreeLocation<'a>,
31}