1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use super::*;
use std::{cell::RefCell, fmt::Debug, rc::Rc};
#[derive(Debug, Clone)]
pub struct StandardContext(Rc<RefCell<ContextMap>>);
impl Default for StandardContext {
fn default() -> Self {
Self::new()
}
}
impl StandardContext {
pub fn new() -> Self {
StandardContext(Rc::new(RefCell::new(ContextMap::new(Document::Unit))))
}
}
impl Context for StandardContext {
fn set_path_inner(&self, path: &[&Document], doc: ContextMapValue) -> Result<()> {
self.0.borrow_mut().set(doc, path)
}
fn get_path_inner(&self, path: &[&Document], ctx: &impl Context) -> Data {
self.0.borrow().exec(ctx, path)
}
fn wrap(&self) -> ContextWrapper {
ContextWrapper::Standard(self)
}
}