From f51c5dc9d53c08ddb4181ea23013e2996edf790c Mon Sep 17 00:00:00 2001 From: Didier Date: Mon, 17 Jul 2023 21:21:29 +0200 Subject: [PATCH] doc: rustdocs --- pkgr/src/package/mod.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/pkgr/src/package/mod.rs b/pkgr/src/package/mod.rs index 349c360..7a7d6b2 100644 --- a/pkgr/src/package/mod.rs +++ b/pkgr/src/package/mod.rs @@ -12,6 +12,7 @@ pub struct Package { } impl Package { + /// Create a new package from a package identifier and a package file. pub fn new(identifier: identifier::PackageIdentifier, pkgfile: pkgfile::PKGFile) -> Package { Package { identifier, @@ -21,11 +22,7 @@ impl Package { } } - pub fn manifest(&self) -> manifest::Manifest { - manifest::Manifest::try_from(self.pkgfile.manifest.clone()) - .unwrap() - } - + /// Fetch a package from a package identifier. pub fn fetch(package_identifier: identifier::PackageIdentifier) -> Result { match &package_identifier { identifier::PackageIdentifier::Path(path) => { @@ -46,6 +43,14 @@ impl Package { } } + /// Get the package manifest. + pub fn manifest(&self) -> manifest::Manifest { + 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); @@ -58,11 +63,18 @@ impl Package { } } + /// Check if the package is installed. pub fn is_installed(&self) -> bool { self.is_installed } + /// Check if the package is indexed. pub fn is_indexed(&self) -> bool { self.is_indexed } + + /// Remove the package from the system. + pub fn remove(&mut self) -> Result<(), ()> { + unimplemented!(); + } } \ No newline at end of file