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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
use crate::{PrivateState, PublicState, Record, State, StateLeaf};
use leo_input::{
tables::{Table, Visibility},
InputParserError,
};
#[derive(Clone, PartialEq, Eq, Default)]
pub struct ProgramState {
public: PublicState,
private: PrivateState,
}
#[allow(clippy::len_without_is_empty)]
impl ProgramState {
pub fn new() -> Self {
Self::default()
}
pub fn empty(&self) -> Self {
let public = self.public.empty();
let private = self.private.empty();
Self { public, private }
}
pub fn len(&self) -> usize {
self.public.len() + self.private.len()
}
pub fn parse(&mut self, table: Table) -> Result<(), InputParserError> {
match table.visibility {
Visibility::Private(_private) => self.private.parse(table.sections),
Visibility::Public(_public) => self.public.parse(table.sections),
}
}
pub fn get_record(&self) -> &Record {
self.private.get_record()
}
pub fn get_state(&self) -> &State {
self.public.get_state()
}
pub fn get_state_leaf(&self) -> &StateLeaf {
self.private.get_state_leaf()
}
}