use std::marker::PhantomData;
use serde_json::Value;
use super::exists_q;
use crate::query::{Query, Root};
#[derive(Debug, Clone)]
pub struct Object<S = Root> {
path: String,
_scope: PhantomData<fn() -> S>,
}
impl<S> Object<S> {
pub fn at(path: impl Into<String>) -> Self {
Self {
path: path.into(),
_scope: PhantomData,
}
}
pub fn exists(&self) -> Query<S> {
exists_q(&self.path)
}
}
#[derive(Debug, Clone)]
pub struct Binary<S = Root> {
path: String,
_scope: PhantomData<fn() -> S>,
}
impl<S> Binary<S> {
pub fn at(path: impl Into<String>) -> Self {
Self {
path: path.into(),
_scope: PhantomData,
}
}
pub fn exists(&self) -> Query<S> {
exists_q(&self.path)
}
}
#[derive(Debug, Clone)]
pub struct Json<S = Root> {
path: String,
_scope: PhantomData<fn() -> S>,
}
impl<S> Json<S> {
pub fn at(path: impl Into<String>) -> Self {
Self {
path: path.into(),
_scope: PhantomData,
}
}
pub fn exists(&self) -> Query<S> {
exists_q(&self.path)
}
pub fn raw(&self, clause: Value) -> Query<S> {
Query::leaf(clause)
}
}