mirror of https://github.com/tauri-apps/tauri
Feature/whitelist (#9)
* feat(proton) whitelist API features * feat(whitelist) fix feature name for execute cmd * fix(whitelist) conflicting command names with q-app * feat(rust2018) cleanup (#8) * rust 2018 edition changes * fix whitespace * change super::super to crate
This commit is contained in:
parent
b9cc35ca39
commit
a1c46cd86f
|
@ -1,3 +1,5 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.1.0"
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
extern crate cc;
|
||||
extern crate pkg_config;
|
||||
|
||||
use std::{
|
||||
env,
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
};
|
||||
use std::{env, path::PathBuf};
|
||||
|
||||
fn main() {
|
||||
let proton_path = PathBuf::from("../../../ui");
|
||||
|
|
|
@ -6,7 +6,10 @@ extern crate bitflags;
|
|||
use std::os::raw::*;
|
||||
|
||||
// https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
|
||||
#[repr(C)] pub struct CWebView { _private: [u8; 0] }
|
||||
#[repr(C)]
|
||||
pub struct CWebView {
|
||||
_private: [u8; 0],
|
||||
}
|
||||
|
||||
type ErasedExternalInvokeFn = extern "C" fn(webview: *mut CWebView, arg: *const c_char);
|
||||
type ErasedDispatchFn = extern "C" fn(webview: *mut CWebView, arg: *mut c_void);
|
||||
|
@ -29,9 +32,18 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
extern {
|
||||
extern "C" {
|
||||
pub fn wrapper_webview_free(this: *mut CWebView);
|
||||
pub fn wrapper_webview_new(title: *const c_char, url: *const c_char, width: c_int, height: c_int, resizable: c_int, debug: c_int, external_invoke_cb: Option<ErasedExternalInvokeFn>, userdata: *mut c_void) -> *mut CWebView;
|
||||
pub fn wrapper_webview_new(
|
||||
title: *const c_char,
|
||||
url: *const c_char,
|
||||
width: c_int,
|
||||
height: c_int,
|
||||
resizable: c_int,
|
||||
debug: c_int,
|
||||
external_invoke_cb: Option<ErasedExternalInvokeFn>,
|
||||
userdata: *mut c_void,
|
||||
) -> *mut CWebView;
|
||||
pub fn webview_loop(this: *mut CWebView, blocking: c_int) -> c_int;
|
||||
pub fn webview_terminate(this: *mut CWebView);
|
||||
pub fn webview_exit(this: *mut CWebView);
|
||||
|
@ -42,5 +54,13 @@ extern {
|
|||
pub fn webview_set_title(this: *mut CWebView, title: *const c_char);
|
||||
pub fn webview_set_fullscreen(this: *mut CWebView, fullscreen: c_int);
|
||||
pub fn webview_set_color(this: *mut CWebView, red: u8, green: u8, blue: u8, alpha: u8);
|
||||
pub fn webview_dialog(this: *mut CWebView, dialog_type: DialogType, flags: DialogFlags, title: *const c_char, arg: *const c_char, result: *mut c_char, result_size: usize);
|
||||
pub fn webview_dialog(
|
||||
this: *mut CWebView,
|
||||
dialog_type: DialogType,
|
||||
flags: DialogFlags,
|
||||
title: *const c_char,
|
||||
arg: *const c_char,
|
||||
result: *mut c_char,
|
||||
result_size: usize,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ pub enum Error {
|
|||
/// WebView was dropped.
|
||||
Dispatch,
|
||||
/// An user-specified error occurred. For use inside invoke and dispatch closures.
|
||||
Custom(Box<CustomError>),
|
||||
Custom(Box<dyn CustomError>),
|
||||
}
|
||||
|
||||
impl Error {
|
||||
|
@ -36,7 +36,7 @@ impl Error {
|
|||
}
|
||||
|
||||
impl error::Error for Error {
|
||||
fn cause(&self) -> Option<&error::Error> {
|
||||
fn cause(&self) -> Option<&dyn error::Error> {
|
||||
match self {
|
||||
Error::NulByte(cause) => Some(cause),
|
||||
_ => None,
|
||||
|
@ -53,7 +53,7 @@ impl error::Error for Error {
|
|||
}
|
||||
|
||||
impl Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Error::UninitializedField(field) => write!(f, "Required field uninitialized: {}.", field),
|
||||
Error::Initialization => write!(f, "Webview failed to initialize."),
|
||||
|
|
|
@ -16,7 +16,7 @@ use std::fmt::{self, Write};
|
|||
///
|
||||
/// view.eval(&format!("callback({});", web_view::escape(string)));
|
||||
/// ```
|
||||
pub fn escape(string: &str) -> Escaper {
|
||||
pub fn escape(string: &str) -> Escaper<'_> {
|
||||
Escaper(string)
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ const SPECIAL: &[char] = &[
|
|||
];
|
||||
|
||||
impl<'a> fmt::Display for Escaper<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let &Escaper(mut string) = self;
|
||||
|
||||
f.write_char('\'')?;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
extern crate boxfnonce;
|
||||
|
||||
extern crate proton_sys as ffi;
|
||||
extern crate urlencoding;
|
||||
|
||||
|
||||
mod color;
|
||||
mod dialog;
|
||||
|
@ -75,7 +75,7 @@ pub struct WebViewBuilder<'a, T: 'a, I, C> {
|
|||
|
||||
impl<'a, T: 'a, I, C> Default for WebViewBuilder<'a, T, I, C>
|
||||
where
|
||||
I: FnMut(&mut WebView<T>, &str) -> WVResult + 'a,
|
||||
I: FnMut(&mut WebView<'_, T>, &str) -> WVResult + 'a,
|
||||
C: AsRef<str>,
|
||||
{
|
||||
fn default() -> Self {
|
||||
|
@ -99,7 +99,7 @@ where
|
|||
|
||||
impl<'a, T: 'a, I, C> WebViewBuilder<'a, T, I, C>
|
||||
where
|
||||
I: FnMut(&mut WebView<T>, &str) -> WVResult + 'a,
|
||||
I: FnMut(&mut WebView<'_, T>, &str) -> WVResult + 'a,
|
||||
C: AsRef<str>,
|
||||
{
|
||||
/// Alias for [`WebViewBuilder::default()`].
|
||||
|
@ -215,7 +215,7 @@ where
|
|||
/// [`WebViewBuilder::default()`]: struct.WebviewBuilder.html#impl-Default
|
||||
pub fn builder<'a, T, I, C>() -> WebViewBuilder<'a, T, I, C>
|
||||
where
|
||||
I: FnMut(&mut WebView<T>, &str) -> WVResult + 'a,
|
||||
I: FnMut(&mut WebView<'_, T>, &str) -> WVResult + 'a,
|
||||
C: AsRef<str>,
|
||||
{
|
||||
WebViewBuilder::new()
|
||||
|
@ -224,7 +224,7 @@ where
|
|||
struct UserData<'a, T> {
|
||||
inner: T,
|
||||
live: Arc<RwLock<()>>,
|
||||
invoke_handler: Box<FnMut(&mut WebView<T>, &str) -> WVResult + 'a>,
|
||||
invoke_handler: Box<dyn FnMut(&mut WebView<'_, T>, &str) -> WVResult + 'a>,
|
||||
result: WVResult,
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ struct UserData<'a, T> {
|
|||
///
|
||||
/// [`WebViewBuilder`]: struct.WebViewBuilder.html
|
||||
#[derive(Debug)]
|
||||
pub struct WebView<'a, T: 'a> {
|
||||
pub struct WebView<'a, T> {
|
||||
inner: *mut CWebView,
|
||||
_phantom: PhantomData<&'a mut T>,
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ impl<'a, T> WebView<'a, T> {
|
|||
invoke_handler: I,
|
||||
) -> WVResult<WebView<'a, T>>
|
||||
where
|
||||
I: FnMut(&mut WebView<T>, &str) -> WVResult + 'a,
|
||||
I: FnMut(&mut WebView<'_, T>, &str) -> WVResult + 'a,
|
||||
{
|
||||
let user_data = Box::new(UserData {
|
||||
inner: user_data,
|
||||
|
@ -275,7 +275,7 @@ impl<'a, T> WebView<'a, T> {
|
|||
);
|
||||
|
||||
if inner.is_null() {
|
||||
Box::<UserData<T>>::from_raw(user_data_ptr);
|
||||
Box::<UserData<'_, T>>::from_raw(user_data_ptr);
|
||||
Err(Error::Initialization)
|
||||
} else {
|
||||
Ok(WebView::from_ptr(inner))
|
||||
|
@ -473,7 +473,7 @@ impl<T> Handle<T> {
|
|||
/// [`step()`]: struct.WebView.html#method.step
|
||||
pub fn dispatch<F>(&self, f: F) -> WVResult
|
||||
where
|
||||
F: FnOnce(&mut WebView<T>) -> WVResult + Send + 'static,
|
||||
F: FnOnce(&mut WebView<'_, T>) -> WVResult + Send + 'static,
|
||||
{
|
||||
// Abort if WebView has been dropped. Otherwise, keep it alive until closure has been
|
||||
// dispatched.
|
||||
|
@ -509,7 +509,7 @@ extern "C" fn ffi_dispatch_handler<T>(webview: *mut CWebView, arg: *mut c_void)
|
|||
let mut handle = mem::ManuallyDrop::new(WebView::<T>::from_ptr(webview));
|
||||
let result = {
|
||||
let callback =
|
||||
Box::<SendBoxFnOnce<'static, (&mut WebView<T>,), WVResult>>::from_raw(arg as _);
|
||||
Box::<SendBoxFnOnce<'static, (&mut WebView<'_, T>,), WVResult>>::from_raw(arg as _);
|
||||
callback.call(&mut handle)
|
||||
};
|
||||
handle.user_data_wrapper_mut().result = result;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -26,3 +26,15 @@ tar = "0.4"
|
|||
flate2 = "1"
|
||||
hyper-old-types = "0.11.0"
|
||||
sysinfo = "0.9"
|
||||
|
||||
[features]
|
||||
api = []
|
||||
all-api = []
|
||||
readTextFile = []
|
||||
readBinaryFile = []
|
||||
writeFile = []
|
||||
listFiles = []
|
||||
listDirs = []
|
||||
setTitle = []
|
||||
execute = []
|
||||
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
mod cmd;
|
||||
|
||||
use proton_ui::WebView;
|
||||
|
||||
#[allow(unused_variables)]
|
||||
pub fn handler<T: 'static>(webview: &mut WebView<'_, T>, arg: &str) -> bool {
|
||||
#[cfg(feature = "api")]
|
||||
{
|
||||
use cmd::Cmd::*;
|
||||
match serde_json::from_str(arg) {
|
||||
Err(_) => false,
|
||||
Ok(command) => {
|
||||
match command {
|
||||
#[cfg(any(feature = "all-api", feature = "readTextFile"))]
|
||||
ReadTextFile {
|
||||
path,
|
||||
callback,
|
||||
error,
|
||||
} => {
|
||||
super::file_system::read_text_file(webview, path, callback, error);
|
||||
}
|
||||
#[cfg(any(feature = "all-api", feature = "readBinaryFile"))]
|
||||
ReadBinaryFile {
|
||||
path,
|
||||
callback,
|
||||
error,
|
||||
} => {
|
||||
super::file_system::read_binary_file(webview, path, callback, error);
|
||||
}
|
||||
#[cfg(any(feature = "all-api", feature = "writeFile"))]
|
||||
WriteFile {
|
||||
file,
|
||||
contents,
|
||||
callback,
|
||||
error,
|
||||
} => {
|
||||
super::file_system::write_file(webview, file, contents, callback, error);
|
||||
}
|
||||
#[cfg(any(feature = "all-api", feature = "listDirs"))]
|
||||
ListDirs {
|
||||
path,
|
||||
callback,
|
||||
error,
|
||||
} => {
|
||||
super::file_system::list_dirs(webview, path, callback, error);
|
||||
}
|
||||
#[cfg(any(feature = "all-api", feature = "listFiles"))]
|
||||
ListFiles {
|
||||
path,
|
||||
callback,
|
||||
error,
|
||||
} => {
|
||||
super::file_system::list(webview, path, callback, error);
|
||||
}
|
||||
#[cfg(any(feature = "all-api", feature = "setTitle"))]
|
||||
SetTitle { title } => {
|
||||
webview.set_title(&title).unwrap();
|
||||
}
|
||||
#[cfg(any(feature = "all-api", feature = "execute"))]
|
||||
Execute {
|
||||
command,
|
||||
args,
|
||||
callback,
|
||||
error,
|
||||
} => {
|
||||
super::command::call(webview, command, args, callback, error);
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
||||
#[cfg(not(feature = "api"))]
|
||||
false
|
||||
}
|
|
@ -1,37 +1,42 @@
|
|||
#[derive(Deserialize)]
|
||||
#[serde(tag = "cmd", rename_all = "camelCase")]
|
||||
#[cfg(feature = "api")]
|
||||
pub enum Cmd {
|
||||
Init,
|
||||
ReadAsString {
|
||||
#[cfg(any(feature = "all-api", feature = "readTextFile"))]
|
||||
ReadTextFile {
|
||||
path: String,
|
||||
callback: String,
|
||||
error: String,
|
||||
},
|
||||
ReadAsBinary {
|
||||
#[cfg(any(feature = "all-api", feature = "readBinaryFile"))]
|
||||
ReadBinaryFile {
|
||||
path: String,
|
||||
callback: String,
|
||||
error: String,
|
||||
},
|
||||
Write {
|
||||
#[cfg(any(feature = "all-api", feature = "writeFile"))]
|
||||
WriteFile {
|
||||
file: String,
|
||||
contents: String,
|
||||
callback: String,
|
||||
error: String,
|
||||
},
|
||||
List {
|
||||
#[cfg(any(feature = "all-api", feature = "listFiles"))]
|
||||
ListFiles {
|
||||
path: String,
|
||||
callback: String,
|
||||
error: String,
|
||||
},
|
||||
#[cfg(any(feature = "all-api", feature = "listDirs"))]
|
||||
ListDirs {
|
||||
path: String,
|
||||
callback: String,
|
||||
error: String,
|
||||
},
|
||||
SetTitle {
|
||||
title: String,
|
||||
},
|
||||
Call {
|
||||
#[cfg(any(feature = "all-api", feature = "setTitle"))]
|
||||
SetTitle { title: String },
|
||||
#[cfg(any(feature = "all-api", feature = "execute"))]
|
||||
Execute {
|
||||
command: String,
|
||||
args: Vec<String>,
|
||||
callback: String,
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
mod cmd;
|
||||
|
||||
use proton_ui::WebView;
|
||||
|
||||
pub fn handler<T: 'static>(webview: &mut WebView<T>, arg: &str) -> bool {
|
||||
use cmd::Cmd::*;
|
||||
match serde_json::from_str(arg) {
|
||||
Err(_) => false,
|
||||
Ok(command) => {
|
||||
match command {
|
||||
Init => (),
|
||||
ReadAsString {
|
||||
path,
|
||||
callback,
|
||||
error,
|
||||
} => {
|
||||
super::file_system::read_text_file(webview, path, callback, error);
|
||||
}
|
||||
ReadAsBinary {
|
||||
path,
|
||||
callback,
|
||||
error,
|
||||
} => {
|
||||
super::file_system::read_binary_file(webview, path, callback, error);
|
||||
}
|
||||
Write {
|
||||
file,
|
||||
contents,
|
||||
callback,
|
||||
error,
|
||||
} => {
|
||||
super::file_system::write_file(webview, file, contents, callback, error);
|
||||
}
|
||||
ListDirs {
|
||||
path,
|
||||
callback,
|
||||
error,
|
||||
} => {
|
||||
super::file_system::list_dirs(webview, path, callback, error);
|
||||
}
|
||||
List {
|
||||
path,
|
||||
callback,
|
||||
error,
|
||||
} => {
|
||||
super::file_system::list(webview, path, callback, error);
|
||||
}
|
||||
SetTitle { title } => {
|
||||
webview.set_title(&title).unwrap();
|
||||
}
|
||||
Call {
|
||||
command,
|
||||
args,
|
||||
callback,
|
||||
error,
|
||||
} => {
|
||||
super::command::call(webview, command, args, callback, error);
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
}
|
|
@ -59,7 +59,7 @@ pub fn spawn_relative_command(
|
|||
}
|
||||
|
||||
pub fn call<T: 'static>(
|
||||
webview: &mut WebView<T>,
|
||||
webview: &mut WebView<'_, T>,
|
||||
command: String,
|
||||
args: Vec<String>,
|
||||
callback: String,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
extern crate dirs;
|
||||
extern crate tempfile;
|
||||
|
||||
use tempfile;
|
||||
|
||||
mod utils;
|
||||
use ignore::Walk;
|
|
@ -1,7 +1,5 @@
|
|||
use std::fs;
|
||||
|
||||
extern crate serde_json;
|
||||
|
||||
mod error;
|
||||
mod extract;
|
||||
mod file_move;
|
|
@ -9,7 +9,7 @@ pub enum Error {
|
|||
}
|
||||
|
||||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
use Error::*;
|
||||
match *self {
|
||||
Extract(ref s) => write!(f, "ExtractError: {}", s),
|
||||
|
@ -24,7 +24,7 @@ impl std::error::Error for Error {
|
|||
"File Error"
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&std::error::Error> {
|
||||
fn cause(&self) -> Option<&dyn std::error::Error> {
|
||||
use Error::*;
|
||||
Some(match *self {
|
||||
Io(ref e) => e,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
extern crate either;
|
||||
extern crate flate2;
|
||||
extern crate tar;
|
||||
extern crate zip;
|
||||
use either;
|
||||
use flate2;
|
||||
use tar;
|
||||
use zip;
|
||||
|
||||
use super::error::*;
|
||||
use crate::file::error::*;
|
||||
use either::Either;
|
||||
use std::fs;
|
||||
use std::io;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::fs;
|
||||
use std::path;
|
||||
|
||||
use super::error::*;
|
||||
use crate::file::error::*;
|
||||
|
||||
/// Moves a file from the given path to the specified destination.
|
||||
///
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
use proton_ui::WebView;
|
||||
|
||||
use super::dir;
|
||||
use super::file;
|
||||
use super::run_async;
|
||||
use crate::dir;
|
||||
use crate::file;
|
||||
use crate::run_async;
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
|
||||
pub fn list<T: 'static>(webview: &mut WebView<T>, path: String, callback: String, error: String) {
|
||||
pub fn list<T: 'static>(
|
||||
webview: &mut WebView<'_, T>,
|
||||
path: String,
|
||||
callback: String,
|
||||
error: String,
|
||||
) {
|
||||
run_async(
|
||||
webview,
|
||||
move || {
|
||||
|
@ -20,7 +25,7 @@ pub fn list<T: 'static>(webview: &mut WebView<T>, path: String, callback: String
|
|||
}
|
||||
|
||||
pub fn list_dirs<T: 'static>(
|
||||
webview: &mut WebView<T>,
|
||||
webview: &mut WebView<'_, T>,
|
||||
path: String,
|
||||
callback: String,
|
||||
error: String,
|
||||
|
@ -37,7 +42,7 @@ pub fn list_dirs<T: 'static>(
|
|||
}
|
||||
|
||||
pub fn write_file<T: 'static>(
|
||||
webview: &mut WebView<T>,
|
||||
webview: &mut WebView<'_, T>,
|
||||
file: String,
|
||||
contents: String,
|
||||
callback: String,
|
||||
|
@ -60,7 +65,7 @@ pub fn write_file<T: 'static>(
|
|||
}
|
||||
|
||||
pub fn read_text_file<T: 'static>(
|
||||
webview: &mut WebView<T>,
|
||||
webview: &mut WebView<'_, T>,
|
||||
path: String,
|
||||
callback: String,
|
||||
error: String,
|
||||
|
@ -80,7 +85,7 @@ pub fn read_text_file<T: 'static>(
|
|||
}
|
||||
|
||||
pub fn read_binary_file<T: 'static>(
|
||||
webview: &mut WebView<T>,
|
||||
webview: &mut WebView<'_, T>,
|
||||
path: String,
|
||||
callback: String,
|
||||
error: String,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
extern crate pbr;
|
||||
extern crate reqwest;
|
||||
use pbr;
|
||||
use reqwest;
|
||||
|
||||
use serde::Serialize;
|
||||
use std::io;
|
|
@ -11,7 +11,7 @@ pub enum Error {
|
|||
}
|
||||
|
||||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
use Error::*;
|
||||
match *self {
|
||||
Download(ref s) => write!(f, "DownloadError: {}", s),
|
||||
|
@ -27,7 +27,7 @@ impl std::error::Error for Error {
|
|||
"Http Error"
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&std::error::Error> {
|
||||
fn cause(&self) -> Option<&dyn std::error::Error> {
|
||||
use Error::*;
|
||||
Some(match *self {
|
||||
Json(ref e) => e,
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
extern crate threadpool;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
|
@ -18,7 +17,6 @@ pub mod tcp;
|
|||
pub mod updater;
|
||||
pub mod version;
|
||||
|
||||
extern crate proton_ui;
|
||||
use proton_ui::WebView;
|
||||
|
||||
use threadpool::ThreadPool;
|
||||
|
@ -26,7 +24,7 @@ use threadpool::ThreadPool;
|
|||
thread_local!(static POOL: ThreadPool = ThreadPool::new(4));
|
||||
|
||||
pub fn run_async<T: 'static, F: FnOnce() -> Result<String, String> + Send + 'static>(
|
||||
webview: &mut WebView<T>,
|
||||
webview: &mut WebView<'_, T>,
|
||||
what: F,
|
||||
callback: String,
|
||||
error: String,
|
||||
|
|
|
@ -8,7 +8,7 @@ pub enum Error {
|
|||
}
|
||||
|
||||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
use Error::*;
|
||||
match *self {
|
||||
Arch(ref s) => write!(f, "ArchError: {}", s),
|
||||
|
@ -23,7 +23,7 @@ impl std::error::Error for Error {
|
|||
"Platform Error"
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&std::error::Error> {
|
||||
fn cause(&self) -> Option<&dyn std::error::Error> {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
extern crate sysinfo;
|
||||
use sysinfo;
|
||||
|
||||
pub use sysinfo::{Process, ProcessExt, Signal, System, SystemExt};
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::net::TcpListener;
|
||||
|
||||
extern crate rand;
|
||||
use rand;
|
||||
|
||||
use rand::distributions::{Distribution, Uniform};
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
extern crate hyper_old_types;
|
||||
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use super::file::{Extract, Move};
|
||||
use super::http;
|
||||
use crate::file::{Extract, Move};
|
||||
use crate::http;
|
||||
|
||||
pub mod github;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
use super::super::file;
|
||||
use super::super::http;
|
||||
use super::super::version;
|
||||
use crate::file;
|
||||
use crate::http;
|
||||
use crate::version;
|
||||
use reqwest;
|
||||
use std;
|
||||
use zip::result::ZipError;
|
||||
|
@ -18,7 +18,7 @@ pub enum Error {
|
|||
}
|
||||
|
||||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
use Error::*;
|
||||
match *self {
|
||||
Updater(ref s) => write!(f, "UpdaterError: {}", s),
|
||||
|
@ -38,7 +38,7 @@ impl std::error::Error for Error {
|
|||
"Updater Error"
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&std::error::Error> {
|
||||
fn cause(&self) -> Option<&dyn std::error::Error> {
|
||||
use Error::*;
|
||||
Some(match *self {
|
||||
Io(ref e) => e,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
mod release;
|
||||
pub use super::error::Error;
|
||||
pub use crate::updater::error::Error;
|
||||
pub use release::*;
|
||||
|
||||
use super::super::http;
|
||||
use crate::http;
|
||||
|
||||
pub fn get_latest_release(repo_owner: &str, repo_name: &str) -> Result<Release, Error> {
|
||||
set_ssl_vars!();
|
|
@ -1,4 +1,4 @@
|
|||
use super::super::error::*;
|
||||
use crate::updater::error::*;
|
||||
use hyper_old_types::header::{LinkValue, RelationType};
|
||||
use serde_json;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ pub enum Error {
|
|||
}
|
||||
|
||||
impl std::fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
use Error::*;
|
||||
match *self {
|
||||
SemVer(ref e) => write!(f, "SemVerError: {}", e),
|
||||
|
@ -20,7 +20,7 @@ impl std::error::Error for Error {
|
|||
"Version Error"
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&std::error::Error> {
|
||||
fn cause(&self) -> Option<&dyn std::error::Error> {
|
||||
use Error::*;
|
||||
Some(match *self {
|
||||
SemVer(ref e) => e,
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "adler32"
|
||||
version = "1.0.3"
|
||||
|
@ -448,7 +450,7 @@ dependencies = [
|
|||
"crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miniz_oxide_c_api 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -630,7 +632,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.2.2"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -638,13 +640,13 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "miniz_oxide_c_api"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"miniz_oxide 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1443,8 +1445,8 @@ dependencies = [
|
|||
"checksum memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2ffa2c986de11a9df78620c01eeaaf27d94d3ff02bf81bfcca953102dd0c6ff"
|
||||
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
|
||||
"checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202"
|
||||
"checksum miniz_oxide 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b6c3756d66cf286314d5f7ebe74886188a9a92f5eee68b06f31ac2b4f314c99d"
|
||||
"checksum miniz_oxide_c_api 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5b78ca5446dd9fe0dab00e058731b6b08a8c1d2b9cdb8efb10876e24e9ae2494"
|
||||
"checksum miniz_oxide 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c061edee74a88eb35d876ce88b94d77a0448a201de111c244b70d047f5820516"
|
||||
"checksum miniz_oxide_c_api 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6c675792957b0d19933816c4e1d56663c341dd9bfa31cb2140ff2267c1d8ecf4"
|
||||
"checksum msi 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a20bdea5e04f55fae0d8f89e88beec71822f2d63f61487ff2205d9d05b677923"
|
||||
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
|
||||
"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09"
|
||||
|
|
|
@ -236,7 +236,7 @@ struct AppCategoryVisitor {
|
|||
impl<'d> serde::de::Visitor<'d> for AppCategoryVisitor {
|
||||
type Value = AppCategory;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self.did_you_mean {
|
||||
Some(string) => write!(
|
||||
formatter,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use crate::ResultExt;
|
||||
use std;
|
||||
use std::ffi::OsStr;
|
||||
use std::fs::{self, File};
|
||||
|
@ -5,7 +6,6 @@ use std::io::{self, BufWriter, Write};
|
|||
use std::path::{Component, Path, PathBuf};
|
||||
use term;
|
||||
use walkdir;
|
||||
use crate::ResultExt;
|
||||
|
||||
/// Returns true if the path has a filename indicating that it is a high-desity
|
||||
/// "retina" icon. Specifically, returns true the the file stem ends with
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
// generate postinst or prerm files.
|
||||
|
||||
use super::common;
|
||||
use crate::{ResultExt, Settings};
|
||||
use ar;
|
||||
use icns;
|
||||
use image::png::{PNGDecoder, PNGEncoder};
|
||||
|
@ -32,7 +33,6 @@ use std::io::{self, Write};
|
|||
use std::path::{Path, PathBuf};
|
||||
use tar;
|
||||
use walkdir::WalkDir;
|
||||
use crate::{ResultExt, Settings};
|
||||
|
||||
pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||
let arch = match settings.binary_arch() {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
// explanation.
|
||||
|
||||
use super::common;
|
||||
use crate::{ResultExt, Settings};
|
||||
use icns;
|
||||
use image::png::{PNGDecoder, PNGEncoder};
|
||||
use image::{self, GenericImage, ImageDecoder};
|
||||
|
@ -17,7 +18,6 @@ use std::ffi::OsStr;
|
|||
use std::fs::{self, File};
|
||||
use std::io::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
use crate::{ResultExt, Settings};
|
||||
|
||||
pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||
common::print_warning("iOS bundle support is still experimental.")?;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use super::common;
|
||||
use super::settings::Settings;
|
||||
use crate::ResultExt;
|
||||
use cab;
|
||||
use msi;
|
||||
use std;
|
||||
|
@ -9,7 +10,6 @@ use std::fs;
|
|||
use std::io::{self, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
use uuid::Uuid;
|
||||
use crate::ResultExt;
|
||||
|
||||
type Package = msi::Package<fs::File>;
|
||||
|
||||
|
@ -319,7 +319,10 @@ fn divide_resources_into_cabinets(mut resources: Vec<ResourceInfo>) -> Vec<Cabin
|
|||
|
||||
// Creates the CAB archives within the package that contain the binary
|
||||
// execuable and all the resource files.
|
||||
fn generate_resource_cabinets(package: &mut Package, cabinets: &[CabinetInfo]) -> crate::Result<()> {
|
||||
fn generate_resource_cabinets(
|
||||
package: &mut Package,
|
||||
cabinets: &[CabinetInfo],
|
||||
) -> crate::Result<()> {
|
||||
for cabinet_info in cabinets.iter() {
|
||||
let mut builder = cab::CabinetBuilder::new();
|
||||
let mut file_map = HashMap::<String, &Path>::new();
|
||||
|
@ -351,7 +354,10 @@ fn generate_resource_cabinets(package: &mut Package, cabinets: &[CabinetInfo]) -
|
|||
}
|
||||
|
||||
// Creates and populates the `Directory` database table for the package.
|
||||
fn create_directory_table(package: &mut Package, directories: &[DirectoryInfo]) -> crate::Result<()> {
|
||||
fn create_directory_table(
|
||||
package: &mut Package,
|
||||
directories: &[DirectoryInfo],
|
||||
) -> crate::Result<()> {
|
||||
package.create_table(
|
||||
"Directory",
|
||||
vec![
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
// files into the `Contents` directory of the bundle.
|
||||
|
||||
use super::common;
|
||||
use crate::{ResultExt, Settings};
|
||||
use chrono;
|
||||
use dirs;
|
||||
use icns;
|
||||
|
@ -28,7 +29,6 @@ use std::fs::{self, File};
|
|||
use std::io::prelude::*;
|
||||
use std::io::{self, BufWriter};
|
||||
use std::path::{Path, PathBuf};
|
||||
use crate::{ResultExt, Settings};
|
||||
|
||||
pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||
let app_bundle_name = format!("{}.app", settings.bundle_name());
|
||||
|
@ -232,7 +232,10 @@ fn copy_frameworks_to_bundle(bundle_directory: &Path, settings: &Settings) -> cr
|
|||
/// Given a list of icon files, try to produce an ICNS file in the resources
|
||||
/// directory and return the path to it. Returns `Ok(None)` if no usable icons
|
||||
/// were provided.
|
||||
fn create_icns_file(resources_dir: &PathBuf, settings: &Settings) -> crate::Result<Option<PathBuf>> {
|
||||
fn create_icns_file(
|
||||
resources_dir: &PathBuf,
|
||||
settings: &Settings,
|
||||
) -> crate::Result<Option<PathBuf>> {
|
||||
if settings.icon_files().count() == 0 {
|
||||
return Ok(None);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use std::path::PathBuf;
|
||||
use crate::Settings;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn bundle_project(_settings: &Settings) -> crate::Result<Vec<PathBuf>> {
|
||||
unimplemented!();
|
||||
|
|
|
@ -138,7 +138,7 @@ impl CargoSettings {
|
|||
}
|
||||
|
||||
impl Settings {
|
||||
pub fn new(current_dir: PathBuf, matches: & ArgMatches) -> crate::Result<Self> {
|
||||
pub fn new(current_dir: PathBuf, matches: &ArgMatches<'_>) -> crate::Result<Self> {
|
||||
let package_type = match matches.value_of("format") {
|
||||
Some(name) => match PackageType::from_short_name(name) {
|
||||
Some(package_type) => Some(package_type),
|
||||
|
@ -159,7 +159,13 @@ impl Settings {
|
|||
None => None,
|
||||
};
|
||||
let features = if matches.is_present("features") {
|
||||
Some(matches.values_of("features").unwrap().map(|s| s.to_string()).collect())
|
||||
Some(
|
||||
matches
|
||||
.values_of("features")
|
||||
.unwrap()
|
||||
.map(|s| s.to_string())
|
||||
.collect(),
|
||||
)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -347,7 +353,7 @@ impl Settings {
|
|||
}
|
||||
|
||||
/// Returns an iterator over the icon files to be used for this bundle.
|
||||
pub fn icon_files(&self) -> ResourcePaths {
|
||||
pub fn icon_files(&self) -> ResourcePaths<'_> {
|
||||
match self.bundle_settings.icon {
|
||||
Some(ref paths) => ResourcePaths::new(paths.as_slice(), false),
|
||||
None => ResourcePaths::new(&[], false),
|
||||
|
@ -356,7 +362,7 @@ impl Settings {
|
|||
|
||||
/// Returns an iterator over the resource files to be included in this
|
||||
/// bundle.
|
||||
pub fn resource_files(&self) -> ResourcePaths {
|
||||
pub fn resource_files(&self) -> ResourcePaths<'_> {
|
||||
match self.bundle_settings.resources {
|
||||
Some(ref paths) => ResourcePaths::new(paths.as_slice(), true),
|
||||
None => ResourcePaths::new(&[], true),
|
||||
|
|
|
@ -1,27 +1,11 @@
|
|||
extern crate ar;
|
||||
extern crate cab;
|
||||
extern crate chrono;
|
||||
#[macro_use]
|
||||
extern crate clap;
|
||||
extern crate dirs;
|
||||
|
||||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
extern crate glob;
|
||||
extern crate icns;
|
||||
extern crate image;
|
||||
extern crate libflate;
|
||||
extern crate md5;
|
||||
extern crate msi;
|
||||
extern crate serde;
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
extern crate strsim;
|
||||
extern crate tar;
|
||||
extern crate target_build_utils;
|
||||
extern crate term;
|
||||
extern crate toml;
|
||||
extern crate uuid;
|
||||
extern crate walkdir;
|
||||
|
||||
#[cfg(test)]
|
||||
extern crate tempfile;
|
||||
|
@ -69,7 +53,7 @@ fn build_project_if_unbuilt(settings: &Settings) -> crate::Result<()> {
|
|||
match settings.build_features() {
|
||||
Some(features) => {
|
||||
args.push(format!("--features={}", features.join(" ")));
|
||||
},
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue