pub struct CratePluginKit<T> { /* private fields */ }Expand description
Generic plugin management library.
Build one and use it serially.
Implementations§
Source§impl<T> CratePluginKit<T>
impl<T> CratePluginKit<T>
Sourcepub fn new(cfg: KitConfig) -> KitResult<Self>
pub fn new(cfg: KitConfig) -> KitResult<Self>
Builds a kit instance from the config. Creates the data directories.
Sourcepub fn install(&self, name: &str, version: Option<&str>) -> KitResult<Installed>
pub fn install(&self, name: &str, version: Option<&str>) -> KitResult<Installed>
Installs a plugin.
name may be a short name ("cargo", to which KitConfig::crate_prefix
is prepended) or a full crate name. With version set to None, the latest
version is looked up on crates.io.
§Errors
KitError::AlreadyInstalled: it is already installed. UseSelf::updateto replace it.
Sourcepub fn update(&self, name: &str, version: Option<&str>) -> KitResult<Installed>
pub fn update(&self, name: &str, version: Option<&str>) -> KitResult<Installed>
Updates (or reinstalls) a plugin. Replaces it if present, installs it if not.
Sourcepub fn uninstall(&self, name: &str) -> KitResult<()>
pub fn uninstall(&self, name: &str) -> KitResult<()>
Uninstalls a plugin.
§Errors
KitError::NotInstalled: it was not installed in the first place.KitError::PluginInUse: this process has loaded its library. A.dllthat is currentlydlopened cannot be deleted on Windows; on Linux the removal succeeds but the disk space is not reclaimed. Rather than gamble on it, ask the user to retry from a clean process.
Sourcepub fn list(&self) -> KitResult<Vec<PluginInfo>>
pub fn list(&self) -> KitResult<Vec<PluginInfo>>
Lists the installed plugins.
The manifests on disk are authoritative; .plugins.json only supplies
information the manifest does not carry, such as the source and install time.
A lost cache therefore never hides a plugin.
Sourcepub fn manifest_of(&self, name: &str) -> KitResult<PluginManifest>
pub fn manifest_of(&self, name: &str) -> KitResult<PluginManifest>
Reads the manifest of one plugin.
Sourcepub fn resolve(&self, name: &str, relative: impl AsRef<Path>) -> PathBuf
pub fn resolve(&self, name: &str, relative: impl AsRef<Path>) -> PathBuf
Resolves a path relative to name into an absolute path.
Sourcepub fn load(&self, name: &str) -> KitResult<LoadedPlugin<T>>
pub fn load(&self, name: &str) -> KitResult<LoadedPlugin<T>>
Loads a plugin and returns a *const T.
Once loaded, Self::uninstall refuses to delete it until the process exits.