pub enum JsonBacktraceBuilder<'a, T: IntoOwned, O = <T as IntoOwned>::Owned> {
Root,
File(&'a Self, T),
Item(&'a Self, JsonFragmentPathItemRef<'a>),
Path(&'a Self, &'a JsonFragmentPathBuf),
Backtrace(&'a Self, &'a JsonBacktrace<O>),
}Expand description
Incrementally builds a JsonBacktraceBuf as a borrow-chain stack,
without allocating until Self::build is called.
Each variant borrows the previous step (&'a Self), so a complete chain
lives on the stack across nested calls; use Self::build to turn it
into an owned JsonBacktraceBuf.
Variants§
Root
Empty backtrace with no frames.
File(&'a Self, T)
Starts a new file frame, extending the previous chain.
Item(&'a Self, JsonFragmentPathItemRef<'a>)
Pushes one navigation step onto the last file frame’s fragment path.
Path(&'a Self, &'a JsonFragmentPathBuf)
Pushes every segment of a path onto the last file frame’s fragment path, in a single step.
Backtrace(&'a Self, &'a JsonBacktrace<O>)
Appends the frames of a previously-built backtrace onto the chain.
Implementations§
Source§impl<T: IntoOwned> JsonBacktraceBuilder<'_, T>
impl<T: IntoOwned> JsonBacktraceBuilder<'_, T>
Sourcepub fn file<'a>(&'a self, file: T) -> JsonBacktraceBuilder<'a, T>
pub fn file<'a>(&'a self, file: T) -> JsonBacktraceBuilder<'a, T>
Starts a new file frame, extending this chain.
Sourcepub fn push<'a>(
&'a self,
item: JsonFragmentPathItemRef<'a>,
) -> JsonBacktraceBuilder<'a, T>
pub fn push<'a>( &'a self, item: JsonFragmentPathItemRef<'a>, ) -> JsonBacktraceBuilder<'a, T>
Pushes a single navigation step onto this chain.
Sourcepub fn push_path<'a>(
&'a self,
path: &'a JsonFragmentPathBuf,
) -> JsonBacktraceBuilder<'a, T>
pub fn push_path<'a>( &'a self, path: &'a JsonFragmentPathBuf, ) -> JsonBacktraceBuilder<'a, T>
Pushes every segment of path, in order, in a single step.
Equivalent to calling Self::push once per segment of path, but
without building an intermediate chain node for each one.
Sourcepub fn push_backtrace<'a>(
&'a self,
backtrace: &'a JsonBacktrace<T::Owned>,
) -> JsonBacktraceBuilder<'a, T>
pub fn push_backtrace<'a>( &'a self, backtrace: &'a JsonBacktrace<T::Owned>, ) -> JsonBacktraceBuilder<'a, T>
Appends the frames of a previously-built backtrace onto this chain, in a single step.
Useful to “jump back” to a location recorded earlier (e.g. where a value was originally defined), while still preserving how the current chain got there.
Sourcepub fn array_index(&self, index: usize) -> JsonBacktraceBuilder<'_, T>
pub fn array_index(&self, index: usize) -> JsonBacktraceBuilder<'_, T>
Push a navigation step to the index-th element of an array.
Sourcepub fn object_entry<'b>(
&'b self,
key: impl Into<&'b str>,
) -> JsonBacktraceBuilder<'b, T>
pub fn object_entry<'b>( &'b self, key: impl Into<&'b str>, ) -> JsonBacktraceBuilder<'b, T>
Push a navigation step to the whole entry (key + value) for the first occurrence of key.
Equivalent to object_entry_at(key, 0). For objects with duplicate keys, use
object_entry_at to specify the occurrence index.
Sourcepub fn object_entry_at<'b>(
&'b self,
key: impl Into<&'b str>,
occurrence: usize,
) -> JsonBacktraceBuilder<'b, T>
pub fn object_entry_at<'b>( &'b self, key: impl Into<&'b str>, occurrence: usize, ) -> JsonBacktraceBuilder<'b, T>
Push a navigation step to the whole entry (key + value) for the occurrence-th occurrence of key.
0 selects the first occurrence, 1 the second, etc.
Sourcepub fn object_key<'b>(
&'b self,
key: impl Into<&'b str>,
) -> JsonBacktraceBuilder<'b, T>
pub fn object_key<'b>( &'b self, key: impl Into<&'b str>, ) -> JsonBacktraceBuilder<'b, T>
Push a navigation step to the key string of the first occurrence of key.
Equivalent to object_key_at(key, 0). For objects with duplicate keys, use
object_key_at to specify the occurrence index.
Sourcepub fn object_key_at<'b>(
&'b self,
key: impl Into<&'b str>,
occurrence: usize,
) -> JsonBacktraceBuilder<'b, T>
pub fn object_key_at<'b>( &'b self, key: impl Into<&'b str>, occurrence: usize, ) -> JsonBacktraceBuilder<'b, T>
Push a navigation step to the key string of the occurrence-th occurrence of key.
0 selects the first occurrence, 1 the second, etc.
Sourcepub fn object_value<'b>(
&'b self,
key: impl Into<&'b str>,
) -> JsonBacktraceBuilder<'b, T>
pub fn object_value<'b>( &'b self, key: impl Into<&'b str>, ) -> JsonBacktraceBuilder<'b, T>
Push a navigation step to the value of the first occurrence of key.
Equivalent to object_value_at(key, 0). For objects with duplicate keys, use
object_value_at to specify the occurrence index.
Sourcepub fn object_value_at<'b>(
&'b self,
key: impl Into<&'b str>,
occurrence: usize,
) -> JsonBacktraceBuilder<'b, T>
pub fn object_value_at<'b>( &'b self, key: impl Into<&'b str>, occurrence: usize, ) -> JsonBacktraceBuilder<'b, T>
Push a navigation step to the value of the occurrence-th occurrence of key.
0 selects the first occurrence, 1 the second, etc.
Sourcepub fn build(self) -> JsonBacktraceBuf<T::Owned>
pub fn build(self) -> JsonBacktraceBuf<T::Owned>
Consumes this chain and produces the equivalent owned
JsonBacktraceBuf.
Trait Implementations§
impl<T: IntoOwned + Copy> Copy for JsonBacktraceBuilder<'_, T>
Source§impl<T: Clone + IntoOwned> From<JsonBacktraceBuilder<'_, T>> for JsonBacktraceBuf<T::Owned>
impl<T: Clone + IntoOwned> From<JsonBacktraceBuilder<'_, T>> for JsonBacktraceBuf<T::Owned>
Source§fn from(value: JsonBacktraceBuilder<'_, T>) -> Self
fn from(value: JsonBacktraceBuilder<'_, T>) -> Self
Auto Trait Implementations§
impl<'a, T, O> Freeze for JsonBacktraceBuilder<'a, T, O>
impl<'a, T, O> RefUnwindSafe for JsonBacktraceBuilder<'a, T, O>where
&'a JsonBacktraceBuilder<'a, T, O>: RefUnwindSafe,
T: RefUnwindSafe,
&'a [JsonBacktraceFrame<O>]: RefUnwindSafe,
impl<'a, T, O> Send for JsonBacktraceBuilder<'a, T, O>
impl<'a, T, O> Sync for JsonBacktraceBuilder<'a, T, O>
impl<'a, T, O> Unpin for JsonBacktraceBuilder<'a, T, O>
impl<'a, T, O> UnsafeUnpin for JsonBacktraceBuilder<'a, T, O>where
&'a JsonBacktraceBuilder<'a, T, O>: UnsafeUnpin,
T: UnsafeUnpin,
&'a [JsonBacktraceFrame<O>]: UnsafeUnpin,
impl<'a, T, O> UnwindSafe for JsonBacktraceBuilder<'a, T, O>where
&'a JsonBacktraceBuilder<'a, T, O>: UnwindSafe,
T: UnwindSafe,
&'a [JsonBacktraceFrame<O>]: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> JsonAt for T
impl<T> JsonAt for T
Source§fn json_at<F>(
self,
location: impl Into<Vec<JsonBacktraceFrame<F>>>,
) -> JsonLocated<T, F>
fn json_at<F>( self, location: impl Into<Vec<JsonBacktraceFrame<F>>>, ) -> JsonLocated<T, F>
self with location.