QoL code and made manager mutable

This commit is contained in:
Maddox Werts 2024-06-23 13:54:12 -04:00
parent 8cf5ea3ec8
commit 4dde4f1596
2 changed files with 18 additions and 17 deletions

View file

@ -3,17 +3,17 @@ use crate::{board, manager};
use std::{io, process::exit};
// Structures
pub struct Interface {
manager: manager::Manager,
pub struct Interface<'a> {
manager: &'a mut manager::Manager,
running: bool,
pub running: bool,
page: u32,
on: u32
}
// Implementations
impl Interface {
pub fn init(manager: manager::Manager) -> Interface{
impl<'a> Interface<'a> {
pub fn init(manager: &'a mut manager::Manager) -> Interface<'a>{
// Return result
return Interface {manager: manager, running: true, page: 0, on: 0};
}
@ -98,15 +98,12 @@ impl Interface {
}
pub fn run(&mut self) {
while self.running {
// Based on the page do something
match self.page {
0 => self.p_0(),
1 => self.p_1(),
2 => self.p_2(),
_ => Interface::error("Invalid Page")
}
}
}
}

View file

@ -14,6 +14,10 @@ fn main() {
managed.parse(String::from("data/user.json"));
// Passing this through to the interface
let mut int: interface::Interface = interface::Interface::init(managed);
let mut int: interface::Interface = interface::Interface::init(&mut managed);
// Running the interface
while int.running {
int.run();
}
}