pub struct PluginService { /* private fields */ }Expand description
插件服务
提供插件的管理、调用、状态检查等功能
对应 TypeScript 版本的 PluginService
Implementations§
Source§impl PluginService
impl PluginService
Sourcepub fn new(registry: Arc<PluginRegistry>) -> Self
pub fn new(registry: Arc<PluginRegistry>) -> Self
创建插件服务
Sourcepub fn from_global() -> Self
pub fn from_global() -> Self
从全局注册表创建插件服务
注意:由于 Rust 的所有权模型,这里创建一个新的服务实例, 但会使用全局注册表。实际使用时,建议通过依赖注入传递同一个注册表实例。
Sourcepub fn with_registry(registry: Arc<PluginRegistry>) -> Self
pub fn with_registry(registry: Arc<PluginRegistry>) -> Self
使用指定的注册表创建插件服务
Sourcepub fn get_config(&self, key: &str) -> Option<Value>
pub fn get_config(&self, key: &str) -> Option<Value>
获取插件配置
对应 TypeScript 版本的 getConfig
Sourcepub fn set_config(&self, key: &str, config: Value)
pub fn set_config(&self, key: &str, config: Value)
设置插件配置
Sourcepub fn get_instance(
&self,
key: &str,
) -> PluginResult<Arc<Mutex<Box<dyn Plugin>>>>
pub fn get_instance( &self, key: &str, ) -> PluginResult<Arc<Mutex<Box<dyn Plugin>>>>
获取插件实例
对应 TypeScript 版本的 getInstance
注意:由于 Rust 的类型系统限制,这里返回的是插件的 Arc 引用
Sourcepub fn check_status(&self, key: &str) -> PluginResult<()>
pub fn check_status(&self, key: &str) -> PluginResult<()>
检查插件状态
对应 TypeScript 版本的 checkStatus
Sourcepub fn set_status(&self, key: &str, status: PluginStatus)
pub fn set_status(&self, key: &str, status: PluginStatus)
设置插件状态
Sourcepub fn enable(&self, key: &str) -> PluginResult<()>
pub fn enable(&self, key: &str) -> PluginResult<()>
启用插件
Sourcepub fn disable(&self, key: &str) -> PluginResult<()>
pub fn disable(&self, key: &str) -> PluginResult<()>
禁用插件
Sourcepub fn get_info(&self, key: &str) -> PluginResult<PluginInfo>
pub fn get_info(&self, key: &str) -> PluginResult<PluginInfo>
获取插件信息
Sourcepub fn list(&self) -> Vec<PluginInfo>
pub fn list(&self) -> Vec<PluginInfo>
获取所有插件信息
对应 TypeScript 版本的 list
Sourcepub fn get_by_hook(&self, hook: &str) -> Vec<PluginInfo>
pub fn get_by_hook(&self, hook: &str) -> Vec<PluginInfo>
获取指定钩子类型的插件
Sourcepub async fn re_init(&self, key: &str) -> PluginResult<()>
pub async fn re_init(&self, key: &str) -> PluginResult<()>
重新初始化插件
对应 TypeScript 版本的 reInit
Sourcepub fn remove(&self, key: &str) -> PluginResult<()>
pub fn remove(&self, key: &str) -> PluginResult<()>
移除插件
对应 TypeScript 版本的 remove
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PluginService
impl !UnwindSafe for PluginService
impl Freeze for PluginService
impl Send for PluginService
impl Sync for PluginService
impl Unpin for PluginService
impl UnsafeUnpin for PluginService
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