Skip to main content

JsonBacktraceBuilder

Enum JsonBacktraceBuilder 

Source
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>

Source

pub fn new() -> &'static Self

Creates an empty stack with no items.

Source

pub fn file<'a>(&'a self, file: T) -> JsonBacktraceBuilder<'a, T>

Starts a new file frame, extending this chain.

Source

pub fn push<'a>( &'a self, item: JsonFragmentPathItemRef<'a>, ) -> JsonBacktraceBuilder<'a, T>

Pushes a single navigation step onto this chain.

Source

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.

Source

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.

Source

pub fn array_index(&self, index: usize) -> JsonBacktraceBuilder<'_, T>

Push a navigation step to the index-th element of an array.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn build(self) -> JsonBacktraceBuf<T::Owned>
where T: Clone, T::Owned: Clone,

Consumes this chain and produces the equivalent owned JsonBacktraceBuf.

Trait Implementations§

Source§

impl<T: IntoOwned + Clone> Clone for JsonBacktraceBuilder<'_, T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: IntoOwned + Copy> Copy for JsonBacktraceBuilder<'_, T>

Source§

impl<'a, T: Debug + IntoOwned, O: Debug> Debug for JsonBacktraceBuilder<'a, T, O>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Clone + IntoOwned> From<JsonBacktraceBuilder<'_, T>> for JsonBacktraceBuf<T::Owned>
where T::Owned: Clone,

Source§

fn from(value: JsonBacktraceBuilder<'_, T>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a, T, O> Freeze for JsonBacktraceBuilder<'a, T, O>
where &'a JsonBacktraceBuilder<'a, T, O>: Freeze, T: Freeze, &'a [JsonBacktraceFrame<O>]: Freeze,

§

impl<'a, T, O> RefUnwindSafe for JsonBacktraceBuilder<'a, T, O>

§

impl<'a, T, O> Send for JsonBacktraceBuilder<'a, T, O>
where &'a JsonBacktraceBuilder<'a, T, O>: Send, T: Send, &'a [JsonBacktraceFrame<O>]: Send,

§

impl<'a, T, O> Sync for JsonBacktraceBuilder<'a, T, O>
where &'a JsonBacktraceBuilder<'a, T, O>: Sync, T: Sync, &'a [JsonBacktraceFrame<O>]: Sync,

§

impl<'a, T, O> Unpin for JsonBacktraceBuilder<'a, T, O>
where &'a JsonBacktraceBuilder<'a, T, O>: Unpin, T: Unpin, &'a [JsonBacktraceFrame<O>]: Unpin,

§

impl<'a, T, O> UnsafeUnpin for JsonBacktraceBuilder<'a, T, O>

§

impl<'a, T, O> UnwindSafe for JsonBacktraceBuilder<'a, T, O>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> JsonAt for T

Source§

fn json_at<F>( self, location: impl Into<Vec<JsonBacktraceFrame<F>>>, ) -> JsonLocated<T, F>

Pairs self with location.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.