Struct rsonpath::query::builder::JsonPathQueryBuilder
source · pub struct JsonPathQueryBuilder { /* private fields */ }
Expand description
Builder for JsonPathQuery
instances.
Examples
let builder = JsonPathQueryBuilder::new()
.child(JsonString::new("a"))
.descendant(JsonString::new("b"))
.any_child()
.child(JsonString::new("c"))
.any_descendant();
// Can also use `builder.build()`.
let query: JsonPathQuery = builder.into();
assert_eq!(format!("{query}"), "$['a']..['b'][*]['c']..[*]");
Implementations§
source§impl JsonPathQueryBuilder
impl JsonPathQueryBuilder
sourcepub fn new() -> Self
pub fn new() -> Self
Initialize an empty builder.
Examples
let builder = JsonPathQueryBuilder::new();
let query: JsonPathQuery = builder.into();
assert_eq!(*query.root(), JsonPathQueryNode::Root(None));
sourcepub fn child(self, member_name: JsonString) -> Self
pub fn child(self, member_name: JsonString) -> Self
Add a child selector with a given member name.
sourcepub fn array_index_child(self, index: NonNegativeArrayIndex) -> Self
pub fn array_index_child(self, index: NonNegativeArrayIndex) -> Self
Add a child selector with a given index.
sourcepub fn array_index_descendant(self, index: NonNegativeArrayIndex) -> Self
pub fn array_index_descendant(self, index: NonNegativeArrayIndex) -> Self
Add a descendant selector with a given index.
sourcepub fn descendant(self, member_name: JsonString) -> Self
pub fn descendant(self, member_name: JsonString) -> Self
Add a descendant selector with a given member_name.
sourcepub fn any_descendant(self) -> Self
pub fn any_descendant(self) -> Self
Add a wildcard descendant selector.
sourcepub fn build(self) -> JsonPathQuery
pub fn build(self) -> JsonPathQuery
Consume the builder and produce a JsonPathQuery
.
Trait Implementations§
source§impl Default for JsonPathQueryBuilder
impl Default for JsonPathQueryBuilder
source§impl From<JsonPathQueryBuilder> for JsonPathQuery
impl From<JsonPathQueryBuilder> for JsonPathQuery
source§fn from(value: JsonPathQueryBuilder) -> Self
fn from(value: JsonPathQueryBuilder) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl RefUnwindSafe for JsonPathQueryBuilder
impl Send for JsonPathQueryBuilder
impl Sync for JsonPathQueryBuilder
impl Unpin for JsonPathQueryBuilder
impl UnwindSafe for JsonPathQueryBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more