flusso_query/handles/
object.rs1use std::marker::PhantomData;
5
6use serde_json::Value;
7
8use super::exists_q;
9use crate::query::{Query, Root};
10
11#[derive(Debug, Clone)]
16pub struct Object<S = Root> {
17 path: String,
18 _scope: PhantomData<fn() -> S>,
19}
20
21impl<S> Object<S> {
22 pub fn at(path: impl Into<String>) -> Self {
23 Self {
24 path: path.into(),
25 _scope: PhantomData,
26 }
27 }
28
29 pub fn exists(&self) -> Query<S> {
31 exists_q(&self.path)
32 }
33}
34
35#[derive(Debug, Clone)]
37pub struct Binary<S = Root> {
38 path: String,
39 _scope: PhantomData<fn() -> S>,
40}
41
42impl<S> Binary<S> {
43 pub fn at(path: impl Into<String>) -> Self {
44 Self {
45 path: path.into(),
46 _scope: PhantomData,
47 }
48 }
49
50 pub fn exists(&self) -> Query<S> {
52 exists_q(&self.path)
53 }
54}
55
56#[derive(Debug, Clone)]
59pub struct Json<S = Root> {
60 path: String,
61 _scope: PhantomData<fn() -> S>,
62}
63
64impl<S> Json<S> {
65 pub fn at(path: impl Into<String>) -> Self {
66 Self {
67 path: path.into(),
68 _scope: PhantomData,
69 }
70 }
71
72 pub fn exists(&self) -> Query<S> {
74 exists_q(&self.path)
75 }
76
77 pub fn raw(&self, clause: Value) -> Query<S> {
79 Query::leaf(clause)
80 }
81}