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()
}
}