#progress #save #state #system #applications #file #restart

jiden

Save and retrive state and progress through a system file

2 releases

0.1.1 Mar 21, 2024
0.1.0 Mar 21, 2024

#5 in #restart

MIT license

6KB
81 lines

Jiden

Crates.io Version

Save and retrive state and progress through a system file

Examples

State Save

let state_saver = StateSaver::new("state.txt");
        
state_saver.save(&1); 
assert_eq!(state_saver.state(), Some(1));

After restarting the application:

let state_saver = StateSaver::new("state.txt");

assert_eq!(state_saver.state(), Some(1));

Progress Save

let state_saver = ProgressSaver::new("state.txt");
        
state_saver.save(0, 1); 
assert_eq!(HashMap::from([(0, 1)]), progress_saver.state());

After restarting the application:

let state_saver = ProgressSaver::new("state.txt");

assert_eq!(HashMap::from([(0, 1)]), progress_saver.state());

Dependencies

~360–770KB
~17K SLoC