pub struct PluginManager {
pub lua: Lua,
}Expand description
Orchestrates Zoi’s extensibility via global Lua plugins.
Plugins allow users to customize Zoi’s behavior by:
- Registering new subcommands (
zoi.register_command). - Intercepting lifecycle events (
zoi.on_post_install, etc.). - Overriding tool versions at runtime (shim resolution).
Plugins are stored in ~/.zoi/plugins/ and are verified against
a trusted_hashes.json database to prevent unauthorized execution.
Fields§
§lua: LuaThe initialized mlua Lua Virtual Machine.
Implementations§
Source§impl PluginManager
impl PluginManager
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Initializes a new PluginManager and sets up the global Lua API.
This injects the entire zoi.* API surface into the Lua environment,
enabling plugins to interact with the filesystem, HTTP, archives,
the UI, and the hook registry.
§Errors
Returns an error if the Lua VM cannot be initialized or if the zoi API
fails to be injected.
Sourcepub fn set_context(&self, scope: Scope) -> Result<()>
pub fn set_context(&self, scope: Scope) -> Result<()>
Sets the operational scope for plugins.
§Errors
Returns an error if the zoi global table cannot be accessed or if the
scope cannot be set.
Sourcepub fn load_all(&self, yes: bool) -> Result<()>
pub fn load_all(&self, yes: bool) -> Result<()>
Loads and executes all trusted Lua plugins from the plugin directory.
§Errors
Returns an error if the plugin directory cannot be read, if a plugin script cannot be loaded, or if a plugin execution fails.
Sourcepub fn trigger_hook(&self, hook_name: &str, arg: Option<&Value>) -> Result<()>
pub fn trigger_hook(&self, hook_name: &str, arg: Option<&Value>) -> Result<()>
Triggers a lifecycle hook, executing all registered callbacks.
§Errors
Returns an error if the hook registry cannot be accessed or if any callback execution fails.
Sourcepub fn trigger_hook_nonfatal(&self, hook_name: &str, arg: Option<&Value>)
pub fn trigger_hook_nonfatal(&self, hook_name: &str, arg: Option<&Value>)
Triggers a lifecycle hook but ignores errors, printing a warning instead.
Sourcepub fn trigger_resolve_shim_version(
&self,
bin_name: &str,
) -> Result<Option<String>>
pub fn trigger_resolve_shim_version( &self, bin_name: &str, ) -> Result<Option<String>>
Triggers the shim version resolution hook.
§Errors
Returns an error if the hook registry cannot be accessed or if any callback execution fails.
Sourcepub fn trigger_project_install_hook(&self) -> Result<bool>
pub fn trigger_project_install_hook(&self) -> Result<bool>
Triggers the project installation hook.
§Errors
Returns an error if the hook registry cannot be accessed or if any callback execution fails.
Auto Trait Implementations§
impl !RefUnwindSafe for PluginManager
impl !Send for PluginManager
impl !Sync for PluginManager
impl !UnwindSafe for PluginManager
impl Freeze for PluginManager
impl Unpin for PluginManager
impl UnsafeUnpin for PluginManager
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
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> ⓘ
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> ⓘ
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