Make platforms generic

This commit is contained in:
Philip Kristoffersen
2021-09-25 08:50:03 +02:00
parent 99079dcaff
commit 9493262076
13 changed files with 136 additions and 93 deletions
+30
View File
@@ -0,0 +1,30 @@
use crate::platform::Platform;
use super::{
get_egs_manifests, get_manifests::EpicGamesManifestsError, EpicGamesLauncherSettings,
ManifestItem,
};
pub struct EpicPlatform {
settings: EpicGamesLauncherSettings,
}
impl EpicPlatform {
pub fn new(settings: EpicGamesLauncherSettings) -> Self {
EpicPlatform { settings }
}
}
impl Platform<ManifestItem, EpicGamesManifestsError> for EpicPlatform {
fn enabled(&self) -> bool {
self.settings.enabled
}
fn name(&self) -> &str {
"EGS"
}
fn get_shortcuts(&self) -> Result<Vec<ManifestItem>, EpicGamesManifestsError> {
get_egs_manifests(&self.settings)
}
}
+2 -2
View File
@@ -19,8 +19,8 @@ pub struct ManifestItem {
pub app_name: String,
}
impl From<&ManifestItem> for ShortcutOwned {
fn from(manifest: &ManifestItem) -> Self {
impl From<ManifestItem> for ShortcutOwned {
fn from(manifest: ManifestItem) -> Self {
let exe = format!(
"\"{}\\{}\"",
manifest.install_location, manifest.launch_executable
+5 -2
View File
@@ -1,6 +1,9 @@
mod get_manifests;
mod manifest_item;
mod settings;
mod epic_platform;
pub use manifest_item::*;
pub use get_manifests::get_egs_manifests;
pub use settings::EpicGamesLauncherSettings;
use get_manifests::get_egs_manifests;
pub use settings::EpicGamesLauncherSettings;
pub use epic_platform::*;
+1 -1
View File
@@ -1,6 +1,6 @@
use serde::Deserialize;
#[derive(Debug, Deserialize)]
#[derive(Debug, Deserialize,Clone)]
pub struct EpicGamesLauncherSettings {
pub enabled: bool,
pub location: Option<String>,