Major overhaul: more generics!

This commit is contained in:
daladim
2021-03-28 19:47:15 +02:00
parent eaa6d8a61e
commit caaddf910c
12 changed files with 314 additions and 163 deletions
+27 -7
View File
@@ -1,17 +1,37 @@
use my_tasks::client::Client;
use std::path::Path;
use my_tasks::{client::Client, traits::CalDavSource};
use my_tasks::cache::Cache;
use my_tasks::Provider;
use my_tasks::settings::URL;
use my_tasks::settings::USERNAME;
use my_tasks::settings::PASSWORD;
const CACHE_FILE: &str = "caldav_cache.json";
#[tokio::main]
async fn main() {
// This is just a function to silence "unused function" warning
/*
let cache_path = Path::new(CACHE_FILE);
let mut client = Client::new(URL, USERNAME, PASSWORD).unwrap();
let calendars = client.get_calendars().await.unwrap();
let _ = calendars.iter()
.map(|cal| println!(" {}\t{}", cal.name(), cal.url().as_str()))
.collect::<()>();
let _ = client.get_tasks(&calendars[3].url()).await;
let mut cache = match Cache::from_file(&cache_path) {
Ok(cache) => cache,
Err(err) => {
log::warn!("Invalid cache file: {}. Using a default cache", err);
Cache::new(&cache_path)
}
};
let provider = Provider::new(client, cache);
let cals = provider.local().get_calendars().await.unwrap();
println!("---- before sync -----");
my_tasks::utils::print_calendar_list(cals);
provider.sync();
println!("---- after sync -----");
my_tasks::utils::print_calendar_list(cals);
*/
}