#[derive(Debug, Deserialize, Serialize)]
struct Config {
smtp_login: String,
- smtp_password: String
+ smtp_password: String,
}
impl Config {
}
const FILE_CONF: &str = "config.ron";
+const PULL_PERIOD: time::Duration = time::Duration::from_secs(60); // 1 min.
fn main() -> Result<()> {
println!("I need a RTX 3080 right now :)");
let client = reqwest::blocking::Client::new();
loop {
+ let time_beginning_loop = time::Instant::now();
println!("Request: {}", url);
match client.get(&url).send() {
).collect();
if match_items.is_empty() {
- println!("No matches -_-´´");
+ println!("No matches 😿");
} else if send_email(&match_items[..], &config.smtp_login, &config.smtp_password) {
- println!("Some matches has been found! An e-mail has been sent!");
+ println!("Some matches has been found 😺! An e-mail has been sent!");
return Ok(())
} else {
println!("Unable to send e-mail");
println!("Error during request: {:?}", error)
}
- thread::sleep(time::Duration::from_secs(60)); // 1 min.
+ let elapsed = time::Instant::now() - time_beginning_loop;
+
+ if elapsed < PULL_PERIOD {
+ let to_wait = PULL_PERIOD - elapsed;
+ thread::sleep(to_wait);
+ }
}
}