Skip to main content

CratePluginKit

Struct CratePluginKit 

Source
pub struct CratePluginKit<T> { /* private fields */ }
Expand description

Generic plugin management library.

Build one and use it serially.

Implementations§

Source§

impl<T> CratePluginKit<T>

Source

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
Source

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
Source

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.

Source

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 .dll that is currently dlopened 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>

Source

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.

Source

pub fn manifest_of(&self, name: &str) -> KitResult<PluginManifest>

Reads the manifest of one plugin.

Source

pub fn resolve(&self, name: &str, relative: impl AsRef<Path>) -> PathBuf

Resolves a path relative to name into an absolute path.

Source

pub fn search( &self, keyword: &str, limit: usize, ) -> KitResult<Vec<CrateSummary>>

Searches for crates.

Source

pub fn view(&self, name: &str) -> KitResult<Option<CrateInfo>>

Looks up a crate by exact name.

Source§

impl<T> CratePluginKit<T>

Source

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.

Source§

impl<T> CratePluginKit<T>

Source

pub fn new(cfg: KitConfig) -> KitResult<Self>

Builds a kit instance from the config. Creates the data directories.

Source

pub fn config(&self) -> &KitConfig

Config.

Source

pub fn paths(&self) -> &KitPaths

The various paths.

Source

pub fn registry(&self) -> &Registry

Registry client.

Auto Trait Implementations§

§

impl<T> !Freeze for CratePluginKit<T>

§

impl<T> !RefUnwindSafe for CratePluginKit<T>

§

impl<T> !Sync for CratePluginKit<T>

§

impl<T> Send for CratePluginKit<T>
where PhantomData<fn() -> T>: Send,

§

impl<T> Unpin for CratePluginKit<T>
where PhantomData<fn() -> T>: Unpin,

§

impl<T> UnsafeUnpin for CratePluginKit<T>
where PhantomData<fn() -> T>: UnsafeUnpin,

§

impl<T> UnwindSafe for CratePluginKit<T>
where PhantomData<fn() -> T>: UnwindSafe,

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.