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 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 crate::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 install_from_path(
&self,
plugin_dir: impl AsRef<Path>,
) -> KitResult<Installed>
pub fn install_from_path( &self, plugin_dir: impl AsRef<Path>, ) -> KitResult<Installed>
Installs a plugin from a checkout on this machine.
The checkout is an ordinary plugin crate: a plain rlib with its manifest beside its
Cargo.toml. It is built exactly the way a published one is — through the same
generated wrapper, landing the same two files — so nothing downstream (loading,
listing, uninstalling) can tell the two apart. What differs is only where the source
comes from.
This is the development loop: build and install what you are working on without
publishing it first. Self::update on such a plugin rebuilds from the same
directory, and the prebuilt download is skipped (there is no release to download).
§Errors
KitError::NoManifest: the directory has noCargo.toml.KitError::ManifestRead: it has no readable<id>-plugin.tomlbeside it.KitError::AlreadyInstalled: that plugin 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.
A plugin that was installed from a checkout is rebuilt from that checkout: the registry has nothing to say about a version that was never published, and rebuilding the directory is what updating it means.
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.
Source§impl<T> CratePluginKit<T>
impl<T> CratePluginKit<T>
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.
Source§impl<T> CratePluginKit<T>
impl<T> CratePluginKit<T>
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.