From cd6881fa0572f56ae67676a22f50d9bbcc1650f0 Mon Sep 17 00:00:00 2001 From: Philip Kristoffersen Date: Sat, 2 Oct 2021 14:03:18 +0200 Subject: [PATCH] remove warnings in ui and non ui builds --- Cargo.lock | 67 +++++++++++++++++++++++++++++++++++++++ Cargo.toml | 4 +-- src/itch/itch_platform.rs | 3 -- src/main.rs | 28 +++++++++------- 4 files changed, 86 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 827477f..fd74d4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,6 +92,7 @@ dependencies = [ "fl2rust", "flate2", "fltk", + "futures", "nom 7.0.0", "nom_locate", "reqwest", @@ -300,6 +301,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" +[[package]] +name = "futures" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + [[package]] name = "futures-channel" version = "0.3.17" @@ -307,6 +323,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -315,6 +332,36 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" +[[package]] +name = "futures-executor" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" + +[[package]] +name = "futures-macro" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" +dependencies = [ + "autocfg", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "futures-sink" version = "0.3.17" @@ -334,10 +381,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" dependencies = [ "autocfg", + "futures-channel", "futures-core", + "futures-io", + "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "pin-utils", + "proc-macro-hack", + "proc-macro-nested", + "slab", ] [[package]] @@ -818,6 +873,18 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro-nested" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" + [[package]] name = "proc-macro2" version = "1.0.29" diff --git a/Cargo.toml b/Cargo.toml index c4fb0bd..8197f5d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,10 +19,10 @@ nom = "^7.0.*" nom_locate = "^3.0.*" flate2 = "^1.0.22" toml = { version = "^0.5.8", optional = true } - +futures = {version="*", optional=true} [build-dependencies] fl2rust = { version = "0.4", optional = true } [features] # default = ["ui"] -ui = ["fltk", "fl2rust", "toml"] +ui = ["fltk", "fl2rust", "toml","futures"] diff --git a/src/itch/itch_platform.rs b/src/itch/itch_platform.rs index de64429..65e9c1d 100644 --- a/src/itch/itch_platform.rs +++ b/src/itch/itch_platform.rs @@ -101,9 +101,6 @@ pub enum ItchErrors { )] PathNotFound { path: String }, - #[fail(display = "Could not read Itch db at {} error: {}", path, error)] - ReadDirError { path: String, error: std::io::Error }, - #[fail(display = "Could not parse Itch db at {} error: {}", path, error)] ParseError { path: String, error: String }, } diff --git a/src/main.rs b/src/main.rs index 8d070e3..0c02e2e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,13 +3,9 @@ use crate::{ origin::OriginPlatform, steamgriddb::{download_images, CachedSearch}, }; -use std::{ - cell::{Ref, RefCell}, - fs::File, - io::Write, - path::Path, - rc::Rc, -}; +#[cfg(feature = "ui")] +use std::{cell::RefCell, rc::Rc}; +use std::{fs::File, io::Write, path::Path}; mod egs; mod itch; mod legendary; @@ -18,12 +14,16 @@ mod platform; mod settings; mod steam; mod steamgriddb; +#[cfg(feature = "ui")] use egs::get_default_location; #[cfg(feature = "ui")] -use fltk::{app, prelude::*, window::Window}; +use fltk::{app, prelude::*}; #[cfg(feature = "ui")] mod mainview; +#[cfg(feature = "ui")] +use futures::executor::block_on; + use crate::{ egs::EpicPlatform, legendary::LegendaryPlatform, @@ -60,8 +60,10 @@ async fn main() -> Result<(), Box> { let sync_settings = settings.clone(); synch_bytton.set_callback(move |cb| { update_settings_with_ui_values(&mut sync_settings.borrow_mut(), &synch_ui); - run_sync(&sync_settings.borrow()); - cb.set_label("Synched"); + match block_on(run_sync(&sync_settings.borrow())) { + Ok(_) => cb.set_label("Synched"), + Err(e) => println!("{}", e), + } }); } @@ -76,6 +78,7 @@ async fn main() -> Result<(), Box> { } } +#[cfg(feature = "ui")] fn empty_or_whitespace(input: String) -> Option { if input.trim().is_empty() { None @@ -83,7 +86,7 @@ fn empty_or_whitespace(input: String) -> Option { Some(input) } } - +#[cfg(feature = "ui")] fn update_settings_with_ui_values(settings: &mut Settings, ui: &mainview::UserInterface) { // Steam location settings.steam.location = empty_or_whitespace(ui.steam_location_input.value()); @@ -109,11 +112,14 @@ fn update_settings_with_ui_values(settings: &mut Settings, ui: &mainview::UserIn settings.itch.location = empty_or_whitespace(ui.itch_locatoin_input.value()); } +#[cfg(feature = "ui")] + fn save_settings_to_file(settings: &Settings) { let toml = toml::to_string(&settings).unwrap(); std::fs::write("config.toml", toml).unwrap(); } +#[cfg(feature = "ui")] fn update_ui_with_settings(ui: &mut mainview::UserInterface, settings: &Settings) { ui.enable_steamgrid_db_checkbox .set_value(settings.steamgrid_db.enabled);