mirror of
https://framagit.org/veretcle/scootaloo.git
synced 2025-07-20 17:11:19 +02:00
39 lines
760 B
Rust
39 lines
760 B
Rust
// auto-imports
|
|
use crate::config::Config;
|
|
|
|
// std
|
|
use std::{
|
|
fs::{read_to_string, write},
|
|
error::Error,
|
|
};
|
|
|
|
// log
|
|
use log::debug;
|
|
|
|
/// Reads last tweet id from a file
|
|
pub fn read_state(s: &str) -> Option<u64> {
|
|
let state = read_to_string(s);
|
|
|
|
if let Ok(s) = state {
|
|
debug!("Last Tweet ID (from file): {}", &s);
|
|
return s.parse::<u64>().ok();
|
|
}
|
|
|
|
None
|
|
}
|
|
|
|
/// Writes last treated tweet id to a file
|
|
pub fn write_state(f: &str, s: u64) -> Result<(), std::io::Error> {
|
|
write(f, format!("{}", s))
|
|
}
|
|
|
|
/*********
|
|
* Main functions
|
|
*********/
|
|
/// Initiates the DB from path
|
|
pub fn init_db(config: &Config) -> Result<(), Box<dyn Error>> {
|
|
println!("config.scootaloo.db_path: {}", config.scootaloo.db_path);
|
|
Ok(())
|
|
}
|
|
|