mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2024-11-22 06:15:38 +01:00
Add framework for fetching metadata about releases
This commit is contained in:
parent
d86077d929
commit
c0eac985ad
16
Cargo.lock
generated
16
Cargo.lock
generated
@ -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"
|
||||
|
@ -23,5 +23,7 @@ toml = "0.4"
|
||||
|
||||
nfd = "0.0.4"
|
||||
|
||||
semver = "0.9.0"
|
||||
|
||||
[build-dependencies]
|
||||
includedir_codegen = "0.2.0"
|
||||
|
@ -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<bool>,
|
||||
pub source: PackageSource
|
||||
}
|
||||
|
||||
/// Describes the application itself.
|
||||
|
11
src/main.rs
11
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,
|
||||
|_| {},
|
||||
|_, _, _| {},
|
||||
(),
|
||||
);
|
||||
}
|
||||
|
@ -36,7 +36,8 @@ struct FileSelection {
|
||||
path: Option<String>,
|
||||
}
|
||||
|
||||
/// 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<InstallerFramework>,
|
||||
}
|
||||
@ -95,6 +97,7 @@ impl Service for WebService {
|
||||
type Error = hyper::Error;
|
||||
type Future = FutureResult<Self::Response, Self::Error>;
|
||||
|
||||
/// 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 <script> tag during loading.
|
||||
|
19
src/sources/github/mod.rs
Normal file
19
src/sources/github/mod.rs
Normal file
@ -0,0 +1,19 @@
|
||||
/// github/mod.rs
|
||||
|
||||
use sources::types::*;
|
||||
|
||||
pub struct GithubReleases {
|
||||
|
||||
}
|
||||
|
||||
/// The configuration for this release.
|
||||
#[derive(Serialize, Deserialize)]
|
||||
struct GithubConfig {
|
||||
repo : String
|
||||
}
|
||||
|
||||
impl ReleaseSource for GithubReleases {
|
||||
fn get_current_releases(&self, config: &TomlValue) -> Result<Vec<Release>, String> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
7
src/sources/mod.rs
Normal file
7
src/sources/mod.rs
Normal file
@ -0,0 +1,7 @@
|
||||
/// sources/mod.rs
|
||||
///
|
||||
/// Contains backends to various release distribution services.
|
||||
|
||||
mod types;
|
||||
|
||||
mod github;
|
79
src/sources/types.rs
Normal file
79
src/sources/types.rs
Normal file
@ -0,0 +1,79 @@
|
||||
/// types.rs
|
||||
///
|
||||
/// Contains traits that should be implemented by sources, as well as corresponding types.
|
||||
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use installer::InstallerFramework;
|
||||
|
||||
pub use semver::Version as SemverVersion;
|
||||
|
||||
pub use toml::value::Value as TomlValue;
|
||||
|
||||
/// The version of an application.
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub enum Version {
|
||||
Semver(SemverVersion),
|
||||
Integer(u64)
|
||||
}
|
||||
|
||||
impl Version {
|
||||
/// Coarses versions into semver versions. This will use a integer version as the major
|
||||
/// field if required.
|
||||
fn coarse_into_semver(&self) -> SemverVersion {
|
||||
match self {
|
||||
&Version::Semver(ref version) => version.to_owned(),
|
||||
&Version::Integer(ref version) => SemverVersion::from((version.to_owned(),
|
||||
0 as u64, 0 as u64))
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a new Version, backed by semver.
|
||||
fn new_semver(version : SemverVersion) -> Version {
|
||||
Version::Semver(version)
|
||||
}
|
||||
|
||||
/// Returns a new Version, backed by a integer.
|
||||
fn new_number(version : u64) -> Version {
|
||||
Version::Integer(version)
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for Version {
|
||||
fn partial_cmp(&self, other: &Version) -> Option<Ordering> {
|
||||
match self {
|
||||
&Version::Semver(ref version) => {
|
||||
match other {
|
||||
&Version::Semver(ref other_version) => Some(version.cmp(other_version)),
|
||||
_ => None
|
||||
}
|
||||
},
|
||||
&Version::Integer(ref num) => {
|
||||
match other {
|
||||
&Version::Integer(ref other_num) => Some(num.cmp(other_num)),
|
||||
_ => None
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for Version {
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
self.coarse_into_semver().cmp(&other.coarse_into_semver())
|
||||
}
|
||||
}
|
||||
|
||||
/// A individual release of an application.
|
||||
#[derive(Debug)]
|
||||
pub struct Release {
|
||||
pub version : Version,
|
||||
pub files : Vec<String>
|
||||
}
|
||||
|
||||
/// A source of releases.
|
||||
pub trait ReleaseSource {
|
||||
/// Gets a list of the available releases from this source. Should cache internally
|
||||
/// if possible using a mutex.
|
||||
fn get_current_releases(&self, config : &TomlValue) -> Result<Vec<Release>, String>;
|
||||
}
|
Loading…
Reference in New Issue
Block a user