format: fix formatting

This commit is contained in:
Strix 2023-10-14 22:39:44 +02:00
parent e3552e9208
commit 9e102ffb52
No known key found for this signature in database
GPG key ID: 49B2E37B8915B774
12 changed files with 80 additions and 85 deletions

View file

@ -1,8 +1,8 @@
use log::trace;
pub mod fetch;
pub mod identifier;
pub mod installer;
pub mod fetch;
pub struct Package {
pub identifier: identifier::PackageIdentifier,
@ -23,43 +23,47 @@ impl Package {
}
/// Fetch a package from a package identifier.
pub fn fetch(package_identifier: identifier::PackageIdentifier) -> Result<Package, fetch::FetchError> {
pub fn fetch(
package_identifier: identifier::PackageIdentifier,
) -> Result<Package, fetch::FetchError> {
match &package_identifier {
identifier::PackageIdentifier::Path(path) => {
trace!("fetching package from path: {}", path);
let pkgfile = fetch::fetch_by_path(path).unwrap();
Ok(Package::new(package_identifier, pkgfile))
},
}
identifier::PackageIdentifier::URI(url) => {
trace!("fetching package from uri: {}", url);
let pkgfile = fetch::fetch_by_uri(url).unwrap();
Ok(Package::new(package_identifier, pkgfile))
},
}
identifier::PackageIdentifier::PackageLocator(locator) => {
trace!("fetching package from locator: {}", locator);
let pkgfile = fetch::fetch_by_package_locator(locator.clone()).unwrap();
Ok(Package::new(package_identifier, pkgfile))
},
}
}
}
/// Get the package manifest.
pub fn manifest(&self) -> manifest::Manifest {
manifest::Manifest::try_from(self.pkgfile.manifest.clone())
.unwrap()
manifest::Manifest::try_from(self.pkgfile.manifest.clone()).unwrap()
}
/// Install the package.
pub fn install(&mut self) -> Result<(), installer::errors::InstallError> {
let manifest = self.manifest();
let installer = installer::PackageInstaller::new(manifest.clone(), self.pkgfile.clone(), installer::InstallType::Bin);
let installer = installer::PackageInstaller::new(
manifest.clone(),
self.pkgfile.clone(),
installer::InstallType::Bin,
);
match installer.install() {
Ok(_) => {
self.is_installed = true;
Ok(())
},
Err(e) => Err(e)
}
Err(e) => Err(e),
}
}
@ -77,4 +81,4 @@ impl Package {
pub fn remove(&mut self) -> Result<(), ()> {
unimplemented!();
}
}
}