diff --git a/Cargo.lock b/Cargo.lock index 5b0a48c..b7b5755 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -494,6 +494,19 @@ dependencies = [ "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "semver" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "semver-parser" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "serde" version = "1.0.27" @@ -759,6 +772,7 @@ dependencies = [ "mime_guess 1.8.3 (registry+https://github.com/rust-lang/crates.io-index)", "nfd 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)", + "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -830,6 +844,8 @@ dependencies = [ "checksum scoped-tls 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f417c22df063e9450888a7561788e9bd46d3bb3c1466435b4eccb903807f147d" "checksum security-framework 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "dfa44ee9c54ce5eecc9de7d5acbad112ee58755239381f687e564004ba4a2332" "checksum security-framework-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "5421621e836278a0b139268f36eee0dc7e389b784dc3f79d8f11aabadf41bead" +"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" +"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "db99f3919e20faa51bb2996057f5031d8685019b5a06139b1ce761da671b8526" "checksum serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "f4ba7591cfe93755e89eeecdbcc668885624829b020050e6aec99c2a03bd3fd0" "checksum serde_derive_internals 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6e03f1c9530c3fb0a0a5c9b826bdd9246a5921ae995d75f512ac917fc4dd55b5" diff --git a/Cargo.toml b/Cargo.toml index 212753e..6a2ee50 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,5 +23,7 @@ toml = "0.4" nfd = "0.0.4" +semver = "0.9.0" + [build-dependencies] includedir_codegen = "0.2.0" diff --git a/src/config.rs b/src/config.rs index 3d3be6b..740429b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -7,12 +7,20 @@ use toml::de::Error as TomlError; use serde_json::{self, Error as SerdeError}; +/// Description of the source of a package. +#[derive(Deserialize, Serialize, Clone)] +pub struct PackageSource { + pub name : String, + pub config : toml::Value +} + /// Describes a overview of a individual package. #[derive(Deserialize, Serialize, Clone)] pub struct PackageDescription { pub name: String, pub description: String, pub default: Option, + pub source: PackageSource } /// Describes the application itself. diff --git a/src/main.rs b/src/main.rs index 83a22de..f5bdc5e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,10 +11,13 @@ extern crate serde_derive; extern crate serde_json; extern crate toml; +extern crate semver; + mod assets; mod rest; mod config; mod installer; +mod sources; use web_view::*; @@ -44,8 +47,6 @@ fn main() { let size = (1024, 550); let resizable = false; let debug = true; - let init_cb = |_| {}; - let userdata = (); run( &format!("{} Installer", app_name), @@ -53,8 +54,8 @@ fn main() { Some(size), resizable, debug, - init_cb, - /* frontend_cb: */ |_, _, _| {}, - userdata, + |_| {}, + |_, _, _| {}, + (), ); } diff --git a/src/rest.rs b/src/rest.rs index e05702a..afdd361 100644 --- a/src/rest.rs +++ b/src/rest.rs @@ -36,7 +36,8 @@ struct FileSelection { path: Option, } -/// Encapsulates Hyper's state. +/// Acts as a communication mechanism between the Hyper WebService and the rest of the +/// application. pub struct WebServer { _handle: JoinHandle<()>, addr: SocketAddr, @@ -85,6 +86,7 @@ impl WebServer { } } +/// Holds internal state for Hyper struct WebService { framework: Arc, } @@ -95,6 +97,7 @@ impl Service for WebService { type Error = hyper::Error; type Future = FutureResult; + /// HTTP request handler fn call(&self, req: Self::Request) -> Self::Future { future::ok(match (req.method(), req.path()) { // This endpoint should be usable directly from a