This commit is contained in:
		
							parent
							
								
									5fea156cfa
								
							
						
					
					
						commit
						f51c5dc9d5
					
				
					 1 changed files with 17 additions and 5 deletions
				
			
		|  | @ -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!(); | ||||
|     } | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue