meta: update to Rust 2018 standard

This commit is contained in:
liushuyu 2020-03-09 00:39:24 -06:00 committed by James
parent 7acefbc8cb
commit 5ff1486f69
37 changed files with 219 additions and 218 deletions

View File

@ -1,6 +1,7 @@
[package]
name = "liftinstall"
version = "0.2.0"
edition = "2018"
authors = ["James <jselby@jselby.net>"]
repository = "https://github.com/j-selby/liftinstall.git"
documentation = "https://liftinstall.jselby.net"

View File

@ -7,8 +7,8 @@ use toml::de::Error as TomlError;
use serde_json::{self, Error as SerdeError};
use sources::get_by_name;
use sources::types::Release;
use crate::sources::get_by_name;
use crate::sources::types::Release;
/// Description of the source of a package.
#[derive(Debug, Deserialize, Serialize, Clone)]

View File

@ -4,8 +4,8 @@
use std::sync::{Arc, RwLock};
use installer::InstallerFramework;
use logging::LoggingErrors;
use crate::installer::InstallerFramework;
use crate::logging::LoggingErrors;
pub mod rest;
mod ui;

View File

@ -2,8 +2,8 @@
extern crate mime_guess;
use self::mime_guess::mime::APPLICATION_OCTET_STREAM;
use self::mime_guess::from_ext;
use self::mime_guess::mime::APPLICATION_OCTET_STREAM;
macro_rules! include_files_as_assets {
( $target_match:expr, $( $file_name:expr ),* ) => {

View File

@ -2,11 +2,11 @@
//!
//! Contains the over-arching server object + methods to manipulate it.
use frontend::rest::services::WebService;
use crate::frontend::rest::services::WebService;
use installer::InstallerFramework;
use crate::installer::InstallerFramework;
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
use hyper::server::Http;

View File

@ -2,23 +2,23 @@
//!
//! The /api/attr call returns an executable script containing session variables.
use frontend::rest::services::default_future;
use frontend::rest::services::Future;
use frontend::rest::services::Request;
use frontend::rest::services::Response;
use frontend::rest::services::WebService;
use crate::frontend::rest::services::default_future;
use crate::frontend::rest::services::Future;
use crate::frontend::rest::services::Request;
use crate::frontend::rest::services::Response;
use crate::frontend::rest::services::WebService;
use hyper::header::{ContentLength, ContentType};
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
pub fn handle(service: &WebService, _req: Request) -> Future {
let framework = service.get_framework_read();
let file = framework
.base_attributes
.to_json_str()
.log_expect("Failed to render JSON representation of config");
.base_attributes
.to_json_str()
.log_expect("Failed to render JSON representation of config");
default_future(
Response::new()

View File

@ -4,18 +4,18 @@
//!
//! This endpoint should be usable directly from a <script> tag during loading.
use frontend::rest::services::Future;
use frontend::rest::services::Request;
use frontend::rest::services::Response;
use frontend::rest::services::WebService;
use crate::frontend::rest::services::Future;
use crate::frontend::rest::services::Request;
use crate::frontend::rest::services::Response;
use crate::frontend::rest::services::WebService;
use hyper::header::{ContentLength, ContentType};
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
use config::Config;
use crate::config::Config;
use http::build_async_client;
use crate::http::build_async_client;
use futures::stream::Stream;
use futures::Future as _;

View File

@ -2,17 +2,17 @@
//!
//! This call returns if dark mode is enabled on the system currently.
use frontend::rest::services::default_future;
use frontend::rest::services::Future;
use frontend::rest::services::Request;
use frontend::rest::services::Response;
use frontend::rest::services::WebService;
use crate::frontend::rest::services::default_future;
use crate::frontend::rest::services::Future;
use crate::frontend::rest::services::Request;
use crate::frontend::rest::services::Response;
use crate::frontend::rest::services::WebService;
use hyper::header::{ContentLength, ContentType};
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
use native::is_dark_mode_active;
use crate::native::is_dark_mode_active;
pub fn handle(_service: &WebService, _req: Request) -> Future {
let file = serde_json::to_string(&is_dark_mode_active())

View File

@ -2,15 +2,15 @@
//!
//! The /api/default-path returns the default path for the application to install into.
use frontend::rest::services::default_future;
use frontend::rest::services::Future;
use frontend::rest::services::Request;
use frontend::rest::services::Response;
use frontend::rest::services::WebService;
use crate::frontend::rest::services::default_future;
use crate::frontend::rest::services::Future;
use crate::frontend::rest::services::Request;
use crate::frontend::rest::services::Response;
use crate::frontend::rest::services::WebService;
use hyper::header::{ContentLength, ContentType};
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
/// Struct used by serde to send a JSON payload to the client containing an optional value.
#[derive(Serialize)]

View File

@ -2,11 +2,11 @@
//!
//! The /api/exit closes down the application.
use frontend::rest::services::default_future;
use frontend::rest::services::Future;
use frontend::rest::services::Request;
use frontend::rest::services::Response;
use frontend::rest::services::WebService;
use crate::frontend::rest::services::default_future;
use crate::frontend::rest::services::Future;
use crate::frontend::rest::services::Request;
use crate::frontend::rest::services::Response;
use crate::frontend::rest::services::WebService;
use hyper::header::ContentType;
use hyper::StatusCode;

View File

@ -2,14 +2,14 @@
//!
//! The /api/install call installs a set of packages dictated by a POST request.
use frontend::rest::services::stream_progress;
use frontend::rest::services::Future;
use frontend::rest::services::Request;
use frontend::rest::services::WebService;
use crate::frontend::rest::services::stream_progress;
use crate::frontend::rest::services::Future;
use crate::frontend::rest::services::Request;
use crate::frontend::rest::services::WebService;
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
use installer::InstallMessage;
use crate::installer::InstallMessage;
use futures::future::Future as _;
use futures::stream::Stream;

View File

@ -5,15 +5,15 @@
//!
//! e.g. if the application is in maintenance mode
use frontend::rest::services::default_future;
use frontend::rest::services::Future;
use frontend::rest::services::Request;
use frontend::rest::services::Response;
use frontend::rest::services::WebService;
use crate::frontend::rest::services::default_future;
use crate::frontend::rest::services::Future;
use crate::frontend::rest::services::Request;
use crate::frontend::rest::services::Response;
use crate::frontend::rest::services::WebService;
use hyper::header::{ContentLength, ContentType};
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
pub fn handle(service: &WebService, _req: Request) -> Future {
let framework = service.get_framework_read();

View File

@ -4,12 +4,12 @@
use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard};
use installer::{InstallMessage, InstallerFramework};
use crate::installer::{InstallMessage, InstallerFramework};
use hyper::server::Service;
use hyper::{Method, StatusCode};
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
use std::sync::mpsc::{channel, Sender};

View File

@ -2,16 +2,16 @@
//!
//! The /api/packages call returns all the currently installed packages.
use frontend::rest::services::default_future;
use frontend::rest::services::encapsulate_json;
use frontend::rest::services::Future;
use frontend::rest::services::Request;
use frontend::rest::services::Response;
use frontend::rest::services::WebService;
use crate::frontend::rest::services::default_future;
use crate::frontend::rest::services::encapsulate_json;
use crate::frontend::rest::services::Future;
use crate::frontend::rest::services::Request;
use crate::frontend::rest::services::Response;
use crate::frontend::rest::services::WebService;
use hyper::header::{ContentLength, ContentType};
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
pub fn handle(service: &WebService, _req: Request) -> Future {
let framework = service.get_framework_read();

View File

@ -4,18 +4,18 @@
//!
//! e.g. index.html, main.js, ...
use frontend::rest::assets;
use crate::frontend::rest::assets;
use frontend::rest::services::default_future;
use frontend::rest::services::Future;
use frontend::rest::services::Request;
use frontend::rest::services::Response;
use frontend::rest::services::WebService;
use crate::frontend::rest::services::default_future;
use crate::frontend::rest::services::Future;
use crate::frontend::rest::services::Request;
use crate::frontend::rest::services::Response;
use crate::frontend::rest::services::WebService;
use hyper::header::{ContentLength, ContentType};
use hyper::StatusCode;
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
pub fn handle(_service: &WebService, req: Request) -> Future {
// At this point, we have a web browser client. Search for a index page

View File

@ -2,15 +2,15 @@
//!
//! The /api/uninstall call uninstalls all packages.
use frontend::rest::services::default_future;
use frontend::rest::services::stream_progress;
use frontend::rest::services::Future;
use frontend::rest::services::Request;
use frontend::rest::services::WebService;
use crate::frontend::rest::services::default_future;
use crate::frontend::rest::services::stream_progress;
use crate::frontend::rest::services::Future;
use crate::frontend::rest::services::Request;
use crate::frontend::rest::services::WebService;
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
use installer::InstallMessage;
use crate::installer::InstallMessage;
pub fn handle(service: &WebService, _req: Request) -> Future {
let framework = service.framework.clone();

View File

@ -2,15 +2,15 @@
//!
//! The /api/update-updater call attempts to update the currently running updater.
use frontend::rest::services::default_future;
use frontend::rest::services::stream_progress;
use frontend::rest::services::Future;
use frontend::rest::services::Request;
use frontend::rest::services::WebService;
use crate::frontend::rest::services::default_future;
use crate::frontend::rest::services::stream_progress;
use crate::frontend::rest::services::Future;
use crate::frontend::rest::services::Request;
use crate::frontend::rest::services::WebService;
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
use installer::InstallMessage;
use crate::installer::InstallMessage;
pub fn handle(service: &WebService, _req: Request) -> Future {
let framework = service.framework.clone();

View File

@ -4,7 +4,7 @@
use web_view::Content;
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
use log::Level;

View File

@ -21,28 +21,28 @@ use std::io::Cursor;
use std::process::Command;
use std::process::{exit, Stdio};
use config::BaseAttributes;
use config::Config;
use crate::config::BaseAttributes;
use crate::config::Config;
use sources::types::Version;
use crate::sources::types::Version;
use tasks::install::InstallTask;
use tasks::uninstall::UninstallTask;
use tasks::uninstall_global_shortcut::UninstallGlobalShortcutsTask;
use tasks::DependencyTree;
use tasks::TaskMessage;
use crate::tasks::install::InstallTask;
use crate::tasks::uninstall::UninstallTask;
use crate::tasks::uninstall_global_shortcut::UninstallGlobalShortcutsTask;
use crate::tasks::DependencyTree;
use crate::tasks::TaskMessage;
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
use dirs::home_dir;
use std::fs::remove_file;
use http;
use crate::http;
use number_prefix::{NumberPrefix, Prefixed, Standalone};
use native;
use crate::native;
/// A message thrown during the installation of packages.
#[derive(Serialize)]

View File

@ -15,7 +15,7 @@ mod natives {
const PROCESS_LEN: usize = 10192;
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
use std::env;
@ -257,7 +257,7 @@ mod natives {
use std::env;
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
use sysinfo::{ProcessExt, SystemExt};

View File

@ -9,7 +9,7 @@ use std::{thread, time};
use clap::{App, ArgMatches};
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
/// Swaps around the main executable if needed.
pub fn perform_swap(current_exe: &PathBuf, to_path: Option<&str>) {

View File

@ -7,9 +7,9 @@ use reqwest::StatusCode;
use serde_json;
use sources::types::*;
use crate::sources::types::*;
use http::build_client;
use crate::http::build_client;
pub struct GithubReleases {}

View File

@ -1,20 +1,20 @@
//! Downloads a package into memory.
use installer::InstallerFramework;
use crate::installer::InstallerFramework;
use tasks::Task;
use tasks::TaskDependency;
use tasks::TaskMessage;
use tasks::TaskOrdering;
use tasks::TaskParamType;
use crate::tasks::Task;
use crate::tasks::TaskDependency;
use crate::tasks::TaskMessage;
use crate::tasks::TaskOrdering;
use crate::tasks::TaskParamType;
use tasks::resolver::ResolvePackageTask;
use crate::tasks::resolver::ResolvePackageTask;
use http::stream_file;
use crate::http::stream_file;
use number_prefix::{NumberPrefix, Prefixed, Standalone};
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
pub struct DownloadPackageTask {
pub name: String,

View File

@ -1,14 +1,14 @@
//! Verifies that this is the only running instance of the installer, and that no application is running.
use installer::InstallerFramework;
use crate::installer::InstallerFramework;
use tasks::Task;
use tasks::TaskDependency;
use tasks::TaskMessage;
use tasks::TaskParamType;
use crate::tasks::Task;
use crate::tasks::TaskDependency;
use crate::tasks::TaskMessage;
use crate::tasks::TaskParamType;
use native::get_process_names;
use native::Process;
use crate::native::get_process_names;
use crate::native::Process;
use std::process;

View File

@ -1,19 +1,19 @@
//! Overall hierarchy for installing a installation of the application.
use installer::InstallerFramework;
use crate::installer::InstallerFramework;
use tasks::ensure_only_instance::EnsureOnlyInstanceTask;
use tasks::install_dir::VerifyInstallDirTask;
use tasks::install_global_shortcut::InstallGlobalShortcutsTask;
use tasks::install_pkg::InstallPackageTask;
use tasks::save_executable::SaveExecutableTask;
use tasks::uninstall_pkg::UninstallPackageTask;
use crate::tasks::ensure_only_instance::EnsureOnlyInstanceTask;
use crate::tasks::install_dir::VerifyInstallDirTask;
use crate::tasks::install_global_shortcut::InstallGlobalShortcutsTask;
use crate::tasks::install_pkg::InstallPackageTask;
use crate::tasks::save_executable::SaveExecutableTask;
use crate::tasks::uninstall_pkg::UninstallPackageTask;
use tasks::Task;
use tasks::TaskDependency;
use tasks::TaskMessage;
use tasks::TaskOrdering;
use tasks::TaskParamType;
use crate::tasks::Task;
use crate::tasks::TaskDependency;
use crate::tasks::TaskMessage;
use crate::tasks::TaskOrdering;
use crate::tasks::TaskParamType;
pub struct InstallTask {
pub items: Vec<String>,

View File

@ -1,16 +1,16 @@
//! Verifies properties about the installation directory.
use installer::InstallerFramework;
use crate::installer::InstallerFramework;
use tasks::Task;
use tasks::TaskDependency;
use tasks::TaskMessage;
use tasks::TaskParamType;
use crate::tasks::Task;
use crate::tasks::TaskDependency;
use crate::tasks::TaskMessage;
use crate::tasks::TaskParamType;
use std::fs::create_dir_all;
use std::fs::read_dir;
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
pub struct VerifyInstallDirTask {
pub clean_install: bool,

View File

@ -1,17 +1,17 @@
//! Generates the global shortcut for this application.
use installer::InstallerFramework;
use crate::installer::InstallerFramework;
use tasks::Task;
use tasks::TaskDependency;
use tasks::TaskMessage;
use tasks::TaskParamType;
use crate::tasks::Task;
use crate::tasks::TaskDependency;
use crate::tasks::TaskMessage;
use crate::tasks::TaskParamType;
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
use native::create_shortcut;
use tasks::save_database::SaveDatabaseTask;
use tasks::TaskOrdering;
use crate::native::create_shortcut;
use crate::tasks::save_database::SaveDatabaseTask;
use crate::tasks::TaskOrdering;
pub struct InstallGlobalShortcutsTask {}

View File

@ -1,26 +1,26 @@
//! Installs a specific package.
use installer::InstallerFramework;
use crate::installer::InstallerFramework;
use tasks::download_pkg::DownloadPackageTask;
use tasks::install_shortcuts::InstallShortcutsTask;
use tasks::save_database::SaveDatabaseTask;
use tasks::uninstall_pkg::UninstallPackageTask;
use tasks::Task;
use tasks::TaskDependency;
use tasks::TaskMessage;
use tasks::TaskOrdering;
use tasks::TaskParamType;
use crate::tasks::download_pkg::DownloadPackageTask;
use crate::tasks::install_shortcuts::InstallShortcutsTask;
use crate::tasks::save_database::SaveDatabaseTask;
use crate::tasks::uninstall_pkg::UninstallPackageTask;
use crate::tasks::Task;
use crate::tasks::TaskDependency;
use crate::tasks::TaskMessage;
use crate::tasks::TaskOrdering;
use crate::tasks::TaskParamType;
use config::PackageDescription;
use installer::LocalInstallation;
use crate::config::PackageDescription;
use crate::installer::LocalInstallation;
use std::fs::create_dir_all;
use std::io::copy;
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
use archives;
use crate::archives;
use std::fs::OpenOptions;
use std::path::Path;

View File

@ -1,17 +1,17 @@
//! Generates shortcuts for a specified file.
use installer::InstallerFramework;
use crate::installer::InstallerFramework;
use tasks::Task;
use tasks::TaskDependency;
use tasks::TaskMessage;
use tasks::TaskParamType;
use crate::tasks::Task;
use crate::tasks::TaskDependency;
use crate::tasks::TaskMessage;
use crate::tasks::TaskParamType;
use config::PackageDescription;
use crate::config::PackageDescription;
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
use native::create_shortcut;
use crate::native::create_shortcut;
pub struct InstallShortcutsTask {
pub name: String,

View File

@ -4,10 +4,10 @@
use std::fmt;
use std::fmt::Display;
use installer::InstallerFramework;
use crate::installer::InstallerFramework;
use sources::types::File;
use sources::types::Version;
use crate::sources::types::File;
use crate::sources::types::Version;
pub mod download_pkg;
pub mod ensure_only_instance;

View File

@ -2,18 +2,18 @@
use std::env::consts::OS;
use installer::InstallerFramework;
use crate::installer::InstallerFramework;
use tasks::Task;
use tasks::TaskDependency;
use tasks::TaskMessage;
use tasks::TaskParamType;
use crate::tasks::Task;
use crate::tasks::TaskDependency;
use crate::tasks::TaskMessage;
use crate::tasks::TaskParamType;
use config::PackageDescription;
use crate::config::PackageDescription;
use regex::Regex;
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
pub struct ResolvePackageTask {
pub name: String,

View File

@ -1,11 +1,11 @@
//! Saves the main database into the installation directory.
use installer::InstallerFramework;
use crate::installer::InstallerFramework;
use tasks::Task;
use tasks::TaskDependency;
use tasks::TaskMessage;
use tasks::TaskParamType;
use crate::tasks::Task;
use crate::tasks::TaskDependency;
use crate::tasks::TaskMessage;
use crate::tasks::TaskParamType;
pub struct SaveDatabaseTask {}

View File

@ -1,11 +1,11 @@
//! Saves the installer executable into the install directory.
use installer::InstallerFramework;
use crate::installer::InstallerFramework;
use tasks::Task;
use tasks::TaskDependency;
use tasks::TaskMessage;
use tasks::TaskParamType;
use crate::tasks::Task;
use crate::tasks::TaskDependency;
use crate::tasks::TaskMessage;
use crate::tasks::TaskParamType;
use std::fs::File;
use std::fs::OpenOptions;
@ -14,7 +14,7 @@ use std::io::copy;
use std::env::current_exe;
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
pub struct SaveExecutableTask {}

View File

@ -1,14 +1,14 @@
//! Uninstalls a set of packages.
use installer::InstallerFramework;
use crate::installer::InstallerFramework;
use tasks::Task;
use tasks::TaskParamType;
use crate::tasks::Task;
use crate::tasks::TaskParamType;
use tasks::uninstall_pkg::UninstallPackageTask;
use tasks::TaskDependency;
use tasks::TaskMessage;
use tasks::TaskOrdering;
use crate::tasks::uninstall_pkg::UninstallPackageTask;
use crate::tasks::TaskDependency;
use crate::tasks::TaskMessage;
use crate::tasks::TaskOrdering;
pub struct UninstallTask {
pub items: Vec<String>,

View File

@ -1,15 +1,15 @@
//! Uninstalls a specific package.
use installer::InstallerFramework;
use crate::installer::InstallerFramework;
use tasks::Task;
use tasks::TaskDependency;
use tasks::TaskMessage;
use tasks::TaskParamType;
use crate::tasks::Task;
use crate::tasks::TaskDependency;
use crate::tasks::TaskMessage;
use crate::tasks::TaskParamType;
use crate::tasks::save_database::SaveDatabaseTask;
use crate::tasks::TaskOrdering;
use std::fs::remove_file;
use tasks::save_database::SaveDatabaseTask;
use tasks::TaskOrdering;
pub struct UninstallGlobalShortcutsTask {}

View File

@ -1,21 +1,21 @@
//! Uninstalls a specific package.
use installer::InstallerFramework;
use crate::installer::InstallerFramework;
use tasks::save_database::SaveDatabaseTask;
use tasks::Task;
use tasks::TaskDependency;
use tasks::TaskMessage;
use tasks::TaskOrdering;
use tasks::TaskParamType;
use crate::tasks::save_database::SaveDatabaseTask;
use crate::tasks::Task;
use crate::tasks::TaskDependency;
use crate::tasks::TaskMessage;
use crate::tasks::TaskOrdering;
use crate::tasks::TaskParamType;
use installer::LocalInstallation;
use crate::installer::LocalInstallation;
use std::fs::remove_dir;
use std::fs::remove_file;
use logging::LoggingErrors;
use tasks::uninstall_shortcuts::UninstallShortcutsTask;
use crate::logging::LoggingErrors;
use crate::tasks::uninstall_shortcuts::UninstallShortcutsTask;
pub struct UninstallPackageTask {
pub name: String,

View File

@ -1,18 +1,18 @@
//! Uninstalls a specific package.
use installer::InstallerFramework;
use crate::installer::InstallerFramework;
use tasks::Task;
use tasks::TaskDependency;
use tasks::TaskMessage;
use tasks::TaskParamType;
use crate::tasks::Task;
use crate::tasks::TaskDependency;
use crate::tasks::TaskMessage;
use crate::tasks::TaskParamType;
use installer::LocalInstallation;
use crate::installer::LocalInstallation;
use std::fs::remove_dir;
use std::fs::remove_file;
use logging::LoggingErrors;
use crate::logging::LoggingErrors;
pub struct UninstallShortcutsTask {
pub name: String,