use crate::basic;
use serde_json::Value;
pub trait DataPathExt {
type Value;
fn path(&self, path: impl AsRef<str>) -> Option<&Self::Value>;
fn path_mut(&mut self, path: impl AsRef<str>) -> Option<&mut Self::Value>;
fn update_or_create(&mut self, path: impl AsRef<str>, value: Self) -> crate::Result<()>;
fn delete(&mut self, path: impl AsRef<str>) -> Option<Self::Value>;
}
impl DataPathExt for Value {
type Value = Self;
fn path(&self, path: impl AsRef<str>) -> Option<&Self::Value> {
basic::get(self, path)
}
fn path_mut(&mut self, path: impl AsRef<str>) -> Option<&mut Self::Value> {
basic::get_mut(self, path)
}
fn update_or_create(&mut self, path: impl AsRef<str>, value: Value) -> crate::Result<()> {
basic::update_or_create(self, path, value)
}
fn delete(&mut self, path: impl AsRef<str>) -> Option<Self::Value> {
basic::delete(self, path)
}
}