use super::super::JsonTreeContext;
use super::super::JsonTreeLocation;
#[derive(Clone)]
pub(in crate::value::traverse) enum OwnedLocation {
Root,
ArrayElement(
usize,
),
ObjectValue(
String,
),
}
impl OwnedLocation {
#[inline(always)]
pub(in crate::value::traverse) fn context(&self, depth: usize) -> JsonTreeContext<'_> {
let location = match self {
Self::Root => JsonTreeLocation::Root,
Self::ArrayElement(index) => JsonTreeLocation::ArrayElement { index: *index },
Self::ObjectValue(key) => JsonTreeLocation::ObjectValue { key },
};
JsonTreeContext { depth, location }
}
}