Struct rsonpath_lib::query::builder::JsonPathQueryBuilder
source · pub struct JsonPathQueryBuilder { /* private fields */ }
Expand description
Builder for JsonPathQuery
instances.
Examples
let builder = JsonPathQueryBuilder::new()
.child(Label::new("a"))
.descendant(Label::new("b"))
.any_child()
.child(Label::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 descendant(self, label: Label) -> Self
pub fn descendant(self, label: Label) -> Self
Add a descendant selector with a given label.
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