I am not using threads and I am trying to use gio::FileExt::query_info
. It will not compile because I did not provide a cancellable type in the option. The docs say I can just provide a None, but this is not working. What type and how would I implement it so the compiler can accept a None?
error[E0283]: type annotations needed
--> src/main.rs:16:42
|
16 | let info: gio::FileInfo = match file.query_info(
| ^^^^^^^^^^ cannot infer type for type parameter `P` declared
| on the associated function `query_info`
|
= note: cannot satisfy `_: IsA<Cancellable>`
My test code is
use gio::File;
fn main() {
let mut filename = glib::get_user_data_dir().unwrap();
filename.push("recipes.db");
let file = File::new_for_path(filename);
assert!(should_try_load(&file));
}
fn should_try_load (file: &gio::File) -> bool {
use gio::FileExt;
let mut result = false;
let info: gio::FileInfo = match file.query_info(
&gio::FILE_ATTRIBUTE_TIME_MODIFIED,
gio::FileQueryInfoFlags::NONE,
None) {
Ok(x) => x,
Err(x) => return result,
};
if info.has_attribute(&gio::FILE_ATTRIBUTE_TIME_MODIFIED) {
let now = glib::DateTime::new_now_utc();
let mtime = info.get_modification_date_time()
.unwrap_or_else(|| now.clone());
result = now.difference(&mtime) < 86400000000; //G_TIME_SPAN_DAY
}
return result
}