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
extern crate alloc;

use alloc::collections::BTreeMap;

use crate::Value;

pub struct StateManager {
    state: BTreeMap<u32, Value>,
}

impl StateManager {
    pub fn new() -> Self {
        Self {
            state: BTreeMap::new(),
        }
    }

    pub fn get_value(&self, index: u32) -> Option<&Value> {
        self.state.get(&index)
    }

    pub fn set_value(&mut self, index: u32, value: Value) {
        self.state.insert(index, value);
    }
}