/* * This file is part of espanso. * * Copyright (C) 2019 Federico Terzi * * espanso is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * espanso is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with espanso. If not, see . */ pub(crate) mod default; pub(crate) mod zip; use serde::{Deserialize, Serialize}; use std::error::Error; use tempfile::TempDir; pub trait PackageManager { fn is_index_outdated(&self) -> bool; fn update_index(&mut self, force: bool) -> Result>; fn get_package(&self, name: &str) -> Option; fn install_package( &self, name: &str, allow_external: bool, proxy: Option, ) -> Result>; fn install_package_from_repo( &self, name: &str, repo_url: &str, proxy: Option, ) -> Result>; fn remove_package(&self, name: &str) -> Result>; fn list_local_packages(&self) -> Vec; } pub trait PackageResolver { fn clone_repo_to_temp( &self, repo_url: &str, proxy: Option, ) -> Result>; } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct Package { pub name: String, pub title: String, pub version: String, pub repo: String, pub desc: String, pub author: String, #[serde(default = "default_is_core")] pub is_core: bool, #[serde(default = "default_original_repo")] pub original_repo: String, } fn default_is_core() -> bool { false } fn default_original_repo() -> String { "".to_owned() } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] pub struct PackageIndex { #[serde(rename = "lastUpdate")] pub last_update: u64, pub packages: Vec, } #[derive(Clone, Debug, PartialEq)] pub enum UpdateResult { NotOutdated, Updated, } #[derive(Clone, Debug, PartialEq)] pub enum InstallResult { NotFoundInIndex, NotFoundInRepo, UnableToParsePackageInfo, MissingPackageVersion, AlreadyInstalled, Installed, BlockedExternalPackage(String), } #[derive(Clone, Debug, PartialEq)] pub enum RemoveResult { NotFound, Removed, }