flake_edit/
state.rs

1use std::collections::HashMap;
2
3use crate::change::Change;
4use crate::input;
5use crate::input::Input;
6
7#[derive(Debug, Default, Clone)]
8pub struct State {
9    // All the parsed inputs that are present in the attr set
10    pub inputs: HashMap<String, Input>,
11    changes: Vec<Change>,
12}
13
14impl State {
15    pub fn add_change(&mut self, change: Change) {
16        self.changes.push(change);
17    }
18    pub fn add_input(&mut self, key: &str, input: Input) {
19        self.inputs.insert(key.into(), input);
20    }
21    pub fn add_follows(&mut self, key: &str, follows: input::Follows) {
22        if let Some(input) = self.inputs.get_mut(key) {
23            input.follows.push(follows);
24        }
25    }
26}