[][src]Struct json_spanned_value::spanned::Spanned

pub struct Spanned<V> { /* fields omitted */ }

A value with start/end position information. Can wrap arbitrary Deserializeable JSON values, not just basic JSON types.

Implementations

impl<V> Spanned<V>[src]

pub fn start(&self) -> usize[src]

Get the starting byte offset (inclusive) of this value. Likely 0 unless loaded through crate::from_*.

pub fn end(&self) -> usize[src]

Get the ending byte offset (non-inclusive) of this value. Likely 0 unless loaded through crate::from_*.

pub fn span(&self) -> (usize, usize)[src]

Get the start .. end byte offset of this value as a (start, end) tuple. Likely (0, 0) unless loaded through crate::from_*.

pub fn range(&self) -> Range<usize>[src]

Get the start .. end byte offset of this value as a start .. end Range. Likely 0 .. 0 unless loaded through crate::from_*.

pub fn into_inner(self) -> V[src]

Get the interior value of the spanned region as an owned value.

pub fn get_ref(&self) -> &V[src]

Get the interior value of the spanned region as a reference.

pub fn get_mut(&mut self) -> &mut V[src]

Get the interior value of the spanned region as a mutable/exclusive reference.

impl Spanned<Value>[src]

Various conversion methods:

  • as_span_[type]() returns borrowing Options of some sort.
  • into_span_[type]() returns Ok(type) or Err(original).

See also on super::Value as provided by Deref implementation:

  • is_[type]() returns bools with obvious meanings.
  • as_[type]() for borrowing Options without span info.
  • into_[type]() for Ok(type) without span info, or Err(original).

pub fn as_span_null(&self) -> Option<Null>[src]

Some(span + ()) if self is null`

pub fn as_span_bool(&self) -> Option<Bool>[src]

Some(span + inner) if self is true or false

pub fn as_span_number(&self) -> Option<Num<'_>>[src]

Some(span + &inner) if self is a number like 123

pub fn as_span_string(&self) -> Option<Str<'_>>[src]

Some(span + &inner) if self is a string like "asdf"

pub fn as_span_array(&self) -> Option<Span<'_>>[src]

Some(span + &inner) if self is an array like [1, 2, 3]

pub fn as_span_object(&self) -> Option<Obj<'_>>[src]

Some(span + &inner) if self is an object like {"a": 1, "b": 2}

pub fn into_span_null(self) -> Result<Null, Self>[src]

Ok(span + ()) if self is null, otherwise Err(self)

pub fn into_span_bool(self) -> Result<Bool, Self>[src]

Ok(span + inner) if self is true or false, otherwise Err(self)

pub fn into_span_number(self) -> Result<Number, Self>[src]

Ok(span + inner) if self is a number like 123, otherwise Err(self)

pub fn into_span_string(self) -> Result<String, Self>[src]

Ok(span + inner) if self is a string like "asdf", otherwise Err(self)

pub fn into_span_array(self) -> Result<Array, Self>[src]

Ok(span + inner) if self is an array like [1, 2, 3], otherwise Err(self)

pub fn into_span_object(self) -> Result<Object, Self>[src]

Ok(span + inner) if self is an object like {"a": 1, "b": 2}, otherwise Err(self)

pub fn pointer(&self, path: &str) -> Option<&Value>[src]

Lookup a value by JSON Pointer (RFC 6901)

pub fn pointer_mut(&mut self, path: &str) -> Option<&mut Value>[src]

Lookup a value by JSON Pointer (RFC 6901)

Trait Implementations

impl<R, V: AsRef<R>> AsRef<R> for Spanned<V>[src]

impl<V: Clone> Clone for Spanned<V>[src]

impl<V: Debug> Debug for Spanned<V>[src]

impl<V> Deref for Spanned<V>[src]

type Target = V

The resulting type after dereferencing.

impl<'de, V: Deserialize<'de>> Deserialize<'de> for Spanned<V>[src]

impl<V: Display> Display for Spanned<V>[src]

impl<V: Eq> Eq for Spanned<V>[src]

impl<V> From<V> for Spanned<V>[src]

impl<V: Hash> Hash for Spanned<V>[src]

impl<'a, K: Hash + Ord + 'a, V: 'a> IntoIterator for &'a Spanned<Map<K, V>>[src]

type Item = (&'a K, &'a V)

The type of the elements being iterated over.

type IntoIter = <&'a IndexMap<K, V> as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?

impl<'a, K: Hash + Ord + 'a, V: 'a> IntoIterator for &'a mut Spanned<Map<K, V>>[src]

type Item = (&'a K, &'a mut V)

The type of the elements being iterated over.

type IntoIter = <&'a mut IndexMap<K, V> as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?

impl<K: Hash + Ord, V> IntoIterator for Spanned<Map<K, V>>[src]

type Item = (K, V)

The type of the elements being iterated over.

type IntoIter = <IndexMap<K, V> as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?

impl<V: Ord> Ord for Spanned<V>[src]

impl<V: PartialEq> PartialEq<Spanned<V>> for Spanned<V>[src]

impl<V: PartialOrd> PartialOrd<Spanned<V>> for Spanned<V>[src]

Auto Trait Implementations

impl<V> RefUnwindSafe for Spanned<V> where
    V: RefUnwindSafe

impl<V> Send for Spanned<V> where
    V: Send

impl<V> Sync for Spanned<V> where
    V: Sync

impl<V> Unpin for Spanned<V> where
    V: Unpin

impl<V> UnwindSafe for Spanned<V> where
    V: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<!> for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.