doc: rustdocs

This commit is contained in:
Strix 2023-10-14 22:39:44 +02:00
parent 3293e407ae
commit e3552e9208
No known key found for this signature in database
GPG key ID: 49B2E37B8915B774

View file

@ -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<Package, fetch::FetchError> {
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!();
}
}