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 crate::actuator::Actuator;
use crate::pattern::{FromPattern, ToPattern};
use crate::transform::Transform;

#[derive(Clone, Copy, Debug)]
pub struct Policy {
    pub parents: bool,
    pub overwrite: bool,
}

#[derive(Clone, Debug)]
pub struct Environment {
    policy: Policy,
}

impl Environment {
    pub fn new(policy: Policy) -> Self {
        Environment { policy }
    }

    pub fn transform<'f, 't>(
        &self,
        from: FromPattern<'f>,
        to: ToPattern<'t>,
    ) -> Transform<'_, 'f, 't> {
        Transform::new(self, from, to)
    }

    pub fn actuator(&self) -> Actuator<'_> {
        Actuator::new(self)
    }

    pub fn policy(&self) -> &Policy {
        &self.policy
    }
}