pub struct PackageManager { /* private fields */ }Expand description
Manages installation, removal, and listing of packages
Implementations§
Source§impl PackageManager
impl PackageManager
Sourcepub fn with_dir(packages_dir: PathBuf) -> Result<Self>
pub fn with_dir(packages_dir: PathBuf) -> Result<Self>
Create a PackageManager with a custom packages directory (for testing)
Sourcepub fn install(&mut self, source: &str) -> Result<PackageManifest>
pub fn install(&mut self, source: &str) -> Result<PackageManifest>
Install a package from a local directory path
Sourcepub fn install_npm(&mut self, name: &str) -> Result<PackageManifest>
pub fn install_npm(&mut self, name: &str) -> Result<PackageManifest>
Install a package from npm
Sourcepub fn update(&mut self, name: &str) -> Result<PackageManifest>
pub fn update(&mut self, name: &str) -> Result<PackageManifest>
Update a package (re-install from the same source).
For npm packages, re-runs npm pack to get the latest version.
For local packages, re-copies from the source path (if available).
Sourcepub fn list(&self) -> Vec<&PackageManifest>
pub fn list(&self) -> Vec<&PackageManifest>
List all installed packages
Sourcepub fn is_installed(&self, name: &str) -> bool
pub fn is_installed(&self, name: &str) -> bool
Check whether a package is installed
Sourcepub fn packages_dir(&self) -> &Path
pub fn packages_dir(&self) -> &Path
Get the packages directory path
Sourcepub fn get_install_dir(&self, name: &str) -> Option<PathBuf>
pub fn get_install_dir(&self, name: &str) -> Option<PathBuf>
Get the install directory for a package (if it exists on disk)
Sourcepub fn discover_resources(&self, name: &str) -> Result<Vec<DiscoveredResource>>
pub fn discover_resources(&self, name: &str) -> Result<Vec<DiscoveredResource>>
Discover all resources from an installed package.
If the manifest lists explicit paths, those are resolved against the install directory. Otherwise, auto-discovery is performed.
Sourcepub fn resource_counts(&self, name: &str) -> Result<ResourceCounts>
pub fn resource_counts(&self, name: &str) -> Result<ResourceCounts>
Get resource counts for a package
Auto Trait Implementations§
impl Freeze for PackageManager
impl RefUnwindSafe for PackageManager
impl Send for PackageManager
impl Sync for PackageManager
impl Unpin for PackageManager
impl UnsafeUnpin for PackageManager
impl UnwindSafe for PackageManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more