Struct chisel_json::paths::JsonPath

source ·
pub struct JsonPath<'a> { /* private fields */ }
Expand description

Struct for creating and manipulating Json paths vaguely compatible with a subset of RFC 8259. Each instance of JsonPath comprises of multiple JsonPathComponents

Implementations§

source§

impl<'a> JsonPath<'a>

source

pub fn new_partial() -> Self

Create a new, partial (no root) JsonPath instance

source

pub fn new() -> Self

Create a new JsonPath instance with just a root component

source

pub fn is_empty(&self) -> bool

Is this an empty path?

source

pub fn is_partial(&self) -> bool

A partial path doesn’t have a JsonPathComponent::Root in the first position

source

pub fn as_string(&self) -> Cow<'a, str>

Render a string (Cow) representation of the path

source

pub fn push_str_selector(&mut self, name: &str)

Push a new JsonPathComponent::NameSelector based on a string slice. Note that no validation is carried out (as of yet) to check whether the name is actually valid and not full of crap

source

pub fn push_index_select(&mut self, index: usize)

Push a new JsonPathComponent::IndexSelector based on a given index

source

pub fn push_range_selector(&mut self, start: usize, end: usize)

Push a new JsonPathComponent::RangeSelector based on a given start and end index

source

pub fn push_wildcard_selector(&mut self)

source

pub fn push(&mut self, component: JsonPathComponent<'a>)

Appends a new JsonPathComponent to the end of the path

source

pub fn pop(&mut self) -> Option<JsonPathComponent<'a>>

Pops the last JsonPathComponent from the end of the path (if it exists)

source

pub fn is_array_path(&self) -> bool

Checks whether a path points to an array element within the source JSON

Trait Implementations§

source§

impl<'a> Add<&JsonPath<'a>> for JsonPath<'a>

source§

fn add(self, rhs: &JsonPath<'a>) -> Self

Concatenate two JsonPath instances. Does some basic checking to ensure that you don’t try and concatenate two rooted paths, or concatenate a rooted path to a partial path

§

type Output = JsonPath<'a>

The resulting type after applying the + operator.
source§

impl<'a> Debug for JsonPath<'a>

source§

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

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

impl<'a> Display for JsonPath<'a>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for JsonPath<'a>

§

impl<'a> Send for JsonPath<'a>

§

impl<'a> Sync for JsonPath<'a>

§

impl<'a> Unpin for JsonPath<'a>

§

impl<'a> UnwindSafe for JsonPath<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.