Skip to main content

PkgManager

Struct PkgManager 

Source
pub struct PkgManager { /* private fields */ }
Expand description

A structure of package manager.

The package manager is used to install packages and remove package. Default sources can be used to download and extract the packages by the package manager. The package manager installs the packages to the Unlab-gpu home directory by default where they are available for a user. Also, the packages can be installed as dependencies of current package by default.

Implementations§

Source§

impl PkgManager

Source

pub fn new( home_dir: PathBuf, work_dir: PathBuf, bin_dir: PathBuf, lib_dir: PathBuf, doc_dir: PathBuf, src_factories: Vec<Arc<dyn SourceCreate + Send + Sync>>, printer: Arc<dyn Print + Send + Sync>, ) -> Result<Self>

Creates a package manager.

This method takes paths to the Unlab-gpu home directory, the work directory, the binary dirtectory, the library directory, and the documentation directory. The factories of default soruces which allows to access to the package. Also, this method takes the printer that prints messages. If the packages isn’t installed as the dependencies for the current package, the path of work directory should be the path to the the Unlab-gpu home directory.

Source

pub fn home_dir(&self) -> &Path

Returns the path to the Unlab-gpu home directory.

Source

pub fn work_dir(&self) -> &Path

Returns the path to the work directory of current package.

Source

pub fn bin_dir(&self) -> &Path

Returns the path to the binary directory.

Source

pub fn lib_dir(&self) -> &Path

Returns the path to the library directory.

Source

pub fn doc_dir(&self) -> &Path

Returns the path to the documentation directory.

Source

pub fn locks(&self) -> &HashMap<PkgName, Version>

Returns the locked versions of packages

Source

pub fn set_locks(&mut self, locks: HashMap<PkgName, Version>)

Sets the locked versions of packages.

Source

pub fn load_locks(&mut self) -> Result<()>

Loads the locked versions of packages.

Source

pub fn save_locks(&self) -> Result<()>

Saves the locked versions of packages.

Source

pub fn save_locks_from_pkg_versions(&self) -> Result<()>

Saves the locked version packages from the database.

Source

pub fn constraints(&self) -> &Arc<HashMap<PkgName, VersionReq>>

Returns the constraints.

Source

pub fn set_constraints( &mut self, constraints: Arc<HashMap<PkgName, VersionReq>>, )

Sets the constraints.

Source

pub fn load_constraints(&mut self) -> Result<()>

Loads the constraints.

Source

pub fn sources(&self) -> &Arc<HashMap<PkgName, SrcInfo>>

Returns the custom sources.

Source

pub fn set_sources(&mut self, sources: Arc<HashMap<PkgName, SrcInfo>>)

Sets the custom sources.

Source

pub fn load_sources(&mut self) -> Result<()>

Loads the custom sources.

Source

pub fn src_factories(&self) -> &[Arc<dyn SourceCreate + Send + Sync>]

Returns the factories of sources.

Source

pub fn printer(&self) -> &Arc<dyn Print + Send + Sync>

Returns the printer.

Source

pub fn manifest() -> Result<Manifest>

Loads the manifest of current package.

Source

pub fn save_manifest(manifest: &Manifest) -> Result<()>

Saves the manifest of current package.

Source

pub fn reset(&mut self)

Resets the package manager.

Source

pub fn constraints_file(&self) -> PathBuf

Returns the path to the constraints.

Source

pub fn sources_file(&self) -> PathBuf

Returns the path to the custom sources.

Source

pub fn work_var_dir(&self) -> PathBuf

Returns the path to the variable directory in the work directory.

Source

pub fn work_tmp_dir(&self) -> PathBuf

Returns the path to the temporary directory in the work directory.

Source

pub fn info_dir(&self) -> PathBuf

Returns the path to the information directory.

Source

pub fn new_part_info_dir(&self) -> PathBuf

Returns the path to the information directory while pre-installing.

Source

pub fn new_info_dir(&self) -> PathBuf

Returns the path to the information directory while installing.

Source

pub fn pkg_info_dir(&self, name: &PkgName) -> PathBuf

Returns the path to the information directory for the specified package.

Source

pub fn pkg_new_part_info_dir(&self, name: &PkgName) -> PathBuf

Returns the path to the information directory while pre-installing for the specified package.

Source

pub fn pkg_new_info_dir(&self, name: &PkgName) -> PathBuf

Returns the path to the information directory while installing for the specified package.

Source

pub fn pkg_tmp_doc_dir(&self, name: &PkgName, version: &Version) -> PathBuf

Returns the path to the documentation directory in the temporary directory for the specified package.

Source

pub fn create_source( &self, name: &PkgName, ) -> Result<Box<dyn Source + Send + Sync>>

Creates a source for the specified package.

Source

pub fn pkg_versions(&self) -> Result<Vec<(PkgName, Version)>>

Returns the package versions.

Source

pub fn pkg_versions_in<F>(&self, f: F) -> Result<()>
where F: FnMut(&PkgName, &Version) -> Result<()>,

Calls the function for each package version.

Source

pub fn pkg_version(&self, name: &PkgName) -> Result<Option<Version>>

Returns the package version if the package is installed, otherwise None.

Source

pub fn pkg_manifest(&self, name: &PkgName) -> Result<Option<Manifest>>

Returns the package manifest if the package is installed, otherwise None.

Source

pub fn pkg_dependents( &self, name: &PkgName, ) -> Result<Option<HashMap<PkgName, VersionReq>>>

Returns the package dependents if the package is installed, otherwise None.

Source

pub fn pkg_paths(&self, name: &PkgName) -> Result<Option<Paths>>

Returns the package paths if the package is installed, otherwise None.

Source

pub fn update(&self, names: &[PkgName]) -> Result<()>

Updates the versions of packages.

Source

pub fn install( &mut self, names: &[PkgName], is_update: bool, is_force: bool, is_doc: bool, ) -> Result<()>

Installs the specified packages with depedencies.

This method overwrites the versions of packages if the update flag is set, otherwise the versions of the packages aren’t updated. If the force flag is set, the packages with the dependencies are reinstalled. The documentations are installed for the packages if the documentation is set, otherwise the documentation aren’t installed.

Source

pub fn install_deps( &mut self, is_update: bool, is_force: bool, is_doc: bool, ) -> Result<()>

Installs the dependencies for the current package.

The unused packages are automatically removed from the work directory. See also install.

Source

pub fn remove(&mut self, names: &[PkgName]) -> Result<()>

Removes the specified packages.

Source

pub fn check_last_op(&self, are_deps: bool) -> Result<()>

Checks whether the preparation to the last operation or the last operations was interrupted.

If the preparation to the last operation or the last operation was interrupted, this method returns an error with the appropriate message.

Source

pub fn cont(&self, is_doc: bool, are_deps: bool) -> Result<()>

Continues the interrupted last operation.

Source

pub fn clean(&self) -> Result<()>

Cleans after the interrupted preparation to the last operation.

Source

pub fn update_all(&self) -> Result<()>

Updates the versions of all packages.

Source

pub fn install_all( &mut self, is_update: bool, is_force: bool, is_doc: bool, ) -> Result<()>

Reinstalls all packages.

See install.

Source

pub fn generate_doc(&self) -> Result<()>

Generates a documentation for the current package.

Source

pub fn generate_std_doc(&self) -> Result<()>

Generates a documentation of the standard built-in functions.

Trait Implementations§

Source§

impl Clone for PkgManager

Source§

fn clone(&self) -> PkgManager

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more