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
34
35
36
use std::{
    path::{Path, PathBuf},
    sync::{Arc, Mutex, RwLock},
};

use crate::{IncludeAdaptor, VarsStack};

#[derive(Clone)]
pub struct WildDocState {
    stack: Arc<RwLock<VarsStack>>,
    cache_dir: PathBuf,
    include_adaptor: Arc<Mutex<Box<dyn IncludeAdaptor + Send>>>,
}

impl WildDocState {
    pub fn new(
        stack: Arc<RwLock<VarsStack>>,
        cache_dir: PathBuf,
        include_adaptor: Arc<Mutex<Box<dyn IncludeAdaptor + Send>>>,
    ) -> Self {
        Self {
            stack,
            cache_dir,
            include_adaptor,
        }
    }
    pub fn cache_dir(&self) -> &Path {
        &self.cache_dir
    }
    pub fn stack(&self) -> Arc<RwLock<VarsStack>> {
        self.stack.clone()
    }
    pub fn include_adaptor(&self) -> &Mutex<Box<dyn IncludeAdaptor + Send>> {
        &self.include_adaptor
    }
}