moving state out of ui
This commit is contained in:
2
client/src/state/mod.rs
Normal file
2
client/src/state/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
// src/state/mod.rs
|
||||
pub mod state;
|
||||
32
client/src/state/state.rs
Normal file
32
client/src/state/state.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
// src/client/ui/handlers/state.rs
|
||||
|
||||
use std::env;
|
||||
|
||||
pub struct AppState {
|
||||
pub is_saved: bool,
|
||||
pub current_dir: String,
|
||||
pub total_count: u64,
|
||||
pub current_position: u64,
|
||||
}
|
||||
|
||||
impl AppState {
|
||||
pub fn new() -> Result<Self, Box<dyn std::error::Error>> {
|
||||
let current_dir = env::current_dir()?
|
||||
.to_string_lossy()
|
||||
.to_string();
|
||||
Ok(AppState {
|
||||
is_saved: false,
|
||||
current_dir,
|
||||
total_count: 0,
|
||||
current_position: 0,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn update_total_count(&mut self, total_count: u64) {
|
||||
self.total_count = total_count;
|
||||
}
|
||||
|
||||
pub fn update_current_position(&mut self, current_position: u64) {
|
||||
self.current_position = current_position;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user