Trait jlens::Selector [] [src]

pub trait Selector: Sized {
    fn select<'a, 'b, F>(&self, input: &JsonPath<'a, 'b>, f: F)
    where
        F: for<'c> FnMut(&JsonPath<'a, 'c>)
; fn boolean(self) -> BooleanSel<Self> { ... } fn uint64(self) -> U64Sel<Self> { ... } fn int64(self) -> I64Sel<Self> { ... } fn float64(self) -> F64Sel<Self> { ... } fn string(self) -> StringSel<Self> { ... } fn object(self) -> ObjectSel<Self> { ... } fn list(self) -> ListSel<Self> { ... } fn null(self) -> NullSel<Self> { ... } fn at(self, index: usize) -> At<Self> { ... } fn key(self, name: &str) -> Key<Self> { ... } fn child(self) -> Child<Self> { ... } fn parent(self) -> Parent<Self> { ... } fn descend(self) -> Descend<Self> { ... } fn ascend(self) -> Ascend<Self> { ... } fn wherein<T: Selector>(self, filter: T) -> Wherein<Self, T> { ... } fn union<T1: Selector, T2: Selector>(
        self,
        left: T1,
        right: T2
    ) -> Union<Self, T1, T2> { ... } fn intersect<T1: Selector, T2: Selector>(
        self,
        left: T1,
        right: T2
    ) -> Intersect<Self, T1, T2> { ... } fn diff<T1: Selector, T2: Selector>(
        self,
        left: T1,
        right: T2
    ) -> Diff<Self, T1, T2> { ... } fn and<T1: Selector, T2: Selector>(
        self,
        left: T1,
        right: T2
    ) -> AndSel<Self, T1, T2> { ... } fn or<T1: Selector, T2: Selector>(
        self,
        left: T1,
        right: T2
    ) -> OrSel<Self, T1, T2> { ... } }

JSON selector trait

Implementors of this trait select nodes from Json objects according to some criteria.

Required Methods

Select matching nodes

Given the path to a single node, input, this method should identify nodes to be selected and invoke the closure f with a path to each.

Provided Methods

Select current node if it is a Json::Boolean

Select current node if it is a Json::U64

Select current node if it is a Json::I64

Select current node if it is a Json::F64

Select current node if it is a Json::String

Select current node if it is a Json::Object

Select current node if it is a Json::Array

Select current node if it is a Json::Null

Select list element

If the current node is a Json::Array of at least index + 1 elements, selects the element at index. Otherwise no nodes are selected.

Select object value for key

If the current node is a Json::Object that contains the key name, its value is selected. Otherwise no nodes are selected.

Select children of current node

Selects all immediate child nodes of the current node: all elements of a Json::Array, or all values of a Json::Object.

Select parent of current node

Selects the parent of the current node if it is not the root, otherwise no nodes are selected.

Select descendents of current node

Selects all child nodes of the current node and all their children, recursively.

Select ancestors of current node

Selects the parent, grandparent, etc. of the current node up to the root of the tree.

Select current node based on filter

Runs the selector filter on the current node. If it selects any nodes, the current node is selected. If it does not select any nodes, no nodes are selected.

Select union of two selectors

Runs left and right on the current node and selects nodes which are selected by either.

Select intersection of two selectors

Runs left and right on the current node and selects nodes which are selected by both.

Select symmetric difference of two selectors

Runs left and right on the current node, selecting nodes which are selected by left but not selected by right.

Warning: this selector will execute its parent in the chain twice which may result in bad performance.

Select logical-and of two selectors

Runs left and right on the current node and selects an arbitrary node if both selected at least one node themselves. This is useful for encoding logical-and conditions for wherein.

Select logical-or of two selectors

Runs left and right on the current node and selects an arbitrary node if either selected at least one node themselves. This is useful for encoding logical-and conditions for wherein.

Implementors