[][src]Trait json_utils::query::Query

pub trait Query<'v>: Sized {
    type ItemRef: Sized + 'v;
    type Item: Sized;
    fn lookup<'p, P>(&'v self, path: P) -> Option<Self::ItemRef>
    where
        P: Path<'p>
;
fn take<'p, P>(self, path: P) -> (Option<Self>, Option<Self::Item>)
    where
        P: Path<'p>
;
fn insert<'p, P>(
        &mut self,
        path: P,
        insertee: Self::Item
    ) -> Result<(), Self::Item>
    where
        P: Path<'p>
; }

Associated Types

type ItemRef: Sized + 'v

type Item: Sized

Loading content...

Required methods

fn lookup<'p, P>(&'v self, path: P) -> Option<Self::ItemRef> where
    P: Path<'p>, 

Lookup for an element under the specified path. Returns an optional reference to the sought element.

fn take<'p, P>(self, path: P) -> (Option<Self>, Option<Self::Item>) where
    P: Path<'p>, 

Takes the element under the specified path out of the queried node. Returns a tuple of two items:

  • optinal remainder of the queried node;
  • optinal taken away element.

fn insert<'p, P>(
    &mut self,
    path: P,
    insertee: Self::Item
) -> Result<(), Self::Item> where
    P: Path<'p>, 

Inserts an element into the queried node under the specified path. Returns Ok(()) if inserted or Err(rejected_element) if could not perform insertion (e.g. path leads to a child of a non-object sub-node).

Loading content...

Implementors

impl<'v> Query<'v> for JsValue[src]

type Item = Self

type ItemRef = &'v Self::Item

impl<'v> Query<'v> for SchemaNode[src]

type Item = QueryNode<SchemaNode>

type ItemRef = QueryNode<&'v SchemaNode>

Loading content...