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"));
// 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 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.