Skip to main content

Resolved

Struct Resolved 

Source
pub struct Resolved<'s, A: Allocator = Global> { /* private fields */ }
Expand description

A JsonView node paired with the source it was parsed from, so string values resolve and keyed navigation work without threading source through every call. Copy, so it chains freely: view.bind(src).get("a").get(0).

Implementations§

Source§

impl<'s, A: Allocator> Resolved<'s, A>

Source

pub fn view(self) -> &'s JsonView<A>

The underlying view node.

Source

pub fn as_bool(self) -> Option<bool>

The boolean value, or None for anything else.

Source

pub fn as_i64(self) -> Option<i64>

The value as an i64, on the same terms as JsonView::as_i64.

Source

pub fn as_u64(self) -> Option<u64>

The value as a u64, on the same terms as JsonView::as_u64.

Source

pub fn as_f64(self) -> Option<f64>

The value as an f64. Unlike JsonView::as_f64, this cursor carries its source, so it can also approximate a BigNumber — the one place where binding to the source widens what is readable. A magnitude f64 cannot hold at all yields None; read it through as_number_str.

Source

pub fn as_str(self) -> Option<&'s str>

The string value, resolved against source (still escaped).

Source

pub fn as_number_str(self) -> Option<&'s str>

The exact decimal text of a big integer that overflowed 64 bits, or None.

Source

pub fn is_null(self) -> bool

Whether this is the null literal. Note a missing child also reads as null, since get returns a Null-backed cursor on a miss; use try_get to tell the two apart.

Source

pub fn is_boolean(self) -> bool

Whether this is true or false.

Source

pub fn is_number(self) -> bool

Whether this is a number of any lane, including one too wide for 64 bits.

Source

pub fn is_string(self) -> bool

Whether this is a string.

Source

pub fn is_array(self) -> bool

Whether this is an array.

Source

pub fn is_object(self) -> bool

Whether this is an object.

Source

pub fn len(self) -> usize

The number of array elements or object entries; 0 for scalars.

Source

pub fn is_empty(self) -> bool

Whether an array or object has no elements. Always false for scalars.

Source

pub fn get<K: ResolveKey<A>>(self, key: K) -> Resolved<'s, A>

Navigates to a child by &str key or usize index, returning a Null-backed cursor on a miss so lookups chain without ?.

Source

pub fn try_get<K: ResolveKey<A>>(self, key: K) -> Option<Resolved<'s, A>>

Like get but distinguishes a miss with None.

Source

pub fn entries(self) -> impl Iterator<Item = (&'s str, Resolved<'s, A>)>

Iterates an object’s entries as (key, value cursor).

Source

pub fn elements(self) -> impl Iterator<Item = Resolved<'s, A>>

Iterates an array’s elements as cursors.

Source

pub fn pointer(self, pointer: &str) -> Resolved<'s, A>

Resolves an RFC 6901 JSON Pointer, returning a Null-backed cursor on a miss.

Source

pub fn try_pointer(self, pointer: &str) -> Option<Resolved<'s, A>>

Like pointer but distinguishes a miss with None.

Source

pub fn write_json<W: Write>(self, writer: &mut W) -> Result

Writes this node as compact JSON, no source argument needed.

Trait Implementations§

Source§

impl<'s, A: Allocator> Clone for Resolved<'s, A>

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<'s, A: Allocator> Copy for Resolved<'s, A>

Source§

impl<'s, A: Allocator> Display for Resolved<'s, A>

Source§

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

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

impl<'s, A: Allocator> Serialize for Resolved<'s, A>

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'s, A> Freeze for Resolved<'s, A>
where &'s JsonView<A>: Freeze,

§

impl<'s, A> RefUnwindSafe for Resolved<'s, A>
where &'s JsonView<A>: RefUnwindSafe,

§

impl<'s, A> Send for Resolved<'s, A>
where &'s JsonView<A>: Send,

§

impl<'s, A> Sync for Resolved<'s, A>
where &'s JsonView<A>: Sync,

§

impl<'s, A> Unpin for Resolved<'s, A>
where &'s JsonView<A>: Unpin,

§

impl<'s, A> UnsafeUnpin for Resolved<'s, A>
where &'s JsonView<A>: UnsafeUnpin,

§

impl<'s, A> UnwindSafe for Resolved<'s, A>
where &'s JsonView<A>: UnwindSafe,

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.