use std::sync::Arc;
#[derive(Clone)]
pub struct ValidationContext {
registry: Arc<dyn RegistryAccess>,
depth: usize,
max_depth: usize,
}
impl ValidationContext {
pub fn new(registry: Arc<dyn RegistryAccess>, max_depth: usize) -> Self {
Self {
registry,
depth: 0,
max_depth,
}
}
pub fn increment_depth(&self) -> Self {
Self {
registry: Arc::clone(&self.registry),
depth: self.depth + 1,
max_depth: self.max_depth,
}
}
pub fn depth(&self) -> usize {
self.depth
}
pub fn max_depth(&self) -> usize {
self.max_depth
}
pub fn registry(&self) -> &dyn RegistryAccess {
&*self.registry
}
}
pub trait RegistryAccess: Send + Sync {
fn get_schema(&self, name: &str) -> Option<Arc<dyn crate::schema::ValueValidator>>;
}