use std::collections::HashMap;
use std::sync::Arc;
use crate::value::ContextValue;
pub(crate) struct ScopeNode {
pub(crate) name: Option<String>,
pub(crate) values: HashMap<&'static str, Arc<dyn ContextValue>>,
pub(crate) parent: Option<Arc<ScopeNode>>,
pub(crate) depth: usize,
pub(crate) remote_chain: Arc<Vec<String>>,
pub(crate) remote_chain_base_depth: usize,
}
pub(crate) struct ScopeGarbage {
pub(crate) _old_values: HashMap<&'static str, Arc<dyn ContextValue>>,
}
pub struct ScopeGuard {
expected_depth: usize,
_not_send: std::marker::PhantomData<*const ()>,
}
impl ScopeGuard {
pub(crate) fn new(expected_depth: usize) -> Self {
Self {
expected_depth,
_not_send: std::marker::PhantomData,
}
}
pub(crate) fn noop() -> Self {
Self {
expected_depth: usize::MAX,
_not_send: std::marker::PhantomData,
}
}
}
impl Drop for ScopeGuard {
fn drop(&mut self) {
crate::storage::leave_scope(self.expected_depth);
}
}