Skip to main content

PluginHandle

Struct PluginHandle 

Source
pub struct PluginHandle { /* private fields */ }
Expand description

插件服务句柄(插件接口层)。 绑定插件身份(plugin_id)、配置(PluginSdkConfig)与能力集,并持有宿主操作契约 Arc<dyn PluginHost>;所有服务操作委托宿主执行,宿主内部再决定直接处理或 转发平台实现。插件通过 HostApi::register() 获取此句柄。

Implementations§

Source§

impl PluginHandle

Source

pub fn new( plugin_id: String, config: PluginSdkConfig, capabilities: PlatformCapabilities, host: Arc<dyn PluginHost>, ) -> Self

绑定插件身份与宿主契约构造句柄。 参数:plugin_id - 插件唯一标识;config - 插件 SDK 配置; capabilities - 平台能力集;host - 宿主操作契约实现。

Source

pub fn plugin_id(&self) -> &str

返回当前插件 ID(宿主模型缓存等按插件隔离目录需要)。

Source

pub fn update_config(&self, config: PluginSdkConfig)

更新插件的 SDK 配置,立即生效,影响后续所有服务调用。

Source

pub fn capabilities(&self) -> &PlatformCapabilities

查询当前平台支持的能力集合。

Source

pub async fn get_icon( &self, request: IconRequest, ) -> Result<Vec<u8>, HostApiError>

根据图标请求提取图标数据,行为由注册时的缓存等级决定。

Source

pub async fn get_icon_or_default(&self, request: IconRequest) -> Vec<u8> ⓘ

提取图标数据,失败时回退到默认图标(永不返回错误)。

Source

pub async fn get_icon_and_update_cache( &self, request: IconRequest, ) -> Result<Vec<u8>, HostApiError>

强制从磁盘提取图标数据并根据缓存等级更新缓存。

Source

pub async fn override_icon_cache( &self, original_request: &IconRequest, custom_icon_path: &str, ) -> Result<(), HostApiError>

覆盖指定 IconRequest 的缓存图标为自定义图标文件。

Source

pub async fn shell_open(&self, target: OpenTarget) -> Result<(), HostApiError>

使用系统默认方式打开目标(文件/网址/文件夹)。

Source

pub async fn shell_open_folder(&self, path: &str) -> Result<(), HostApiError>

在文件资源管理器中打开指定路径的父目录并选中该文件。

Source

pub async fn shell_execute_elevation( &self, path: &str, ) -> Result<(), HostApiError>

以管理员权限启动程序。

Source

pub async fn shell_execute_command( &self, command: &str, ) -> Result<(), HostApiError>

执行命令字符串(后台运行,无窗口)。

Source

pub async fn activate_window_by_process( &self, process_name: &str, ) -> Result<bool, HostApiError>

根据进程名(如 “chrome.exe”)激活已存在的窗口。

Source

pub async fn activate_window_by_title( &self, title: &str, ) -> Result<bool, HostApiError>

根据窗口标题的部分内容激活已存在的窗口。

Source

pub async fn activate_window_by_pid( &self, pid: u32, ) -> Result<bool, HostApiError>

根据进程 PID 激活已存在的窗口。

Source

pub fn resolve_path(&self, path: KnownPath) -> Result<String, HostApiError>

根据已知路径类型解析实际文件系统路径。

Source

pub fn set_clipboard_text(&self, text: &str) -> Result<(), HostApiError>

将文本写入系统剪贴板。

Source

pub async fn enumerate_apps(&self) -> Vec<AppInfo>

枚举当前平台已安装的应用。

Source

pub async fn launch_app( &self, app_id: &str, args: Option<&[String]>, ) -> Result<u32, HostApiError>

启动指定应用。

Source

pub fn get_app_icon_path(&self, name: &str) -> Option<String>

根据名称获取内置图标资源的文件系统路径。

Source

pub fn resolve_lnk_target(&self, lnk_path: &str) -> Option<String>

解析 .lnk 快捷方式文件的目标路径。

Source

pub fn parse_localized_names_from_dir( &self, dir_path: &Path, ) -> HashMap<String, String>

解析指定目录下的 desktop.ini 文件,提取 [LocalizedFileNames] 部分。

Source

pub fn get_theme(&self) -> Result<Theme, HostApiError>

查询宿主当前实际生效的界面主题(system 模式由宿主解析)。

Source

pub fn get_system_theme(&self) -> Result<Theme, HostApiError>

查询系统主题(未应用宿主显式 light/dark 配置)。

Source

pub fn model_list(&self) -> Vec<ModelInfo>

全网模型清单(聚合缓存,含所有已注册提供方)。

Source

pub async fn model_chat( &self, req: ModelChatRequest, ) -> Result<ModelChatResponse, ModelError>

按 model_id 调用文本生成。

Source

pub async fn model_embedding( &self, req: ModelEmbeddingRequest, ) -> Result<ModelEmbeddingResponse, ModelError>

按 model_id 调用文本向量化(task_type 必填)。

Source

pub async fn model_similarity( &self, req: ModelSimilarityRequest, ) -> Result<ModelSimilarityResponse, ModelError>

按 model_id 计算查询向量与多个目标向量的相似度。

Source

pub async fn resolve_parameters( &self, template: &str, user_args: &[String], snapshot: &ParameterSnapshot, ) -> Result<String, HostApiError>

解析参数模板。

Source

pub fn count_user_parameters(&self, template: &str) -> usize

统计模板中需要用户输入的参数数量。

Source

pub fn has_system_parameters(&self, template: &str) -> bool

检查模板是否包含系统参数。

Source

pub async fn set_timeout( &self, delay: Duration, callback: TimerCallback, ) -> Result<TimerId, HostApiError>

创建一个一次性定时器,在指定延迟后触发回调。

Source

pub async fn set_interval( &self, interval: Duration, callback: TimerCallback, ) -> Result<TimerId, HostApiError>

创建一个重复定时器,每隔指定间隔触发回调。

Source

pub async fn cancel_timer(&self, id: TimerId) -> Result<(), HostApiError>

取消指定 ID 的定时器。

Source

pub async fn cancel_all_timers(&self) -> Result<(), HostApiError>

取消所有定时器。

Source

pub async fn resource_upload( &self, resource_id: &str, file_path: &str, max_size: Option<u64>, ) -> Result<String, HostApiError>

上传资源文件到本插件的资源空间。

Source

pub async fn resource_put( &self, resource_id: &str, data: &[u8], ) -> Result<(), HostApiError>

直接写入资源字节数据,无需先创建临时文件或提供本地路径。

Source

pub async fn resource_get( &self, resource_id: &str, ) -> Result<Vec<u8>, HostApiError>

获取资源文件内容。

Source

pub async fn resource_delete( &self, resource_id: &str, ) -> Result<(), HostApiError>

删除资源文件。

Source

pub async fn resource_list(&self) -> Result<Vec<String>, HostApiError>

列出本插件的所有资源。

Source

pub async fn cache_put( &self, domain: &str, key: &str, data: &[u8], ) -> Result<(), HostApiError>

写入插件本地缓存。 与 resource_* 的区别:缓存存放可再生的本地数据(如模型向量), 不经过 StorageService,仅落在本地缓存目录。

Source

pub async fn cache_get( &self, domain: &str, key: &str, ) -> Result<Option<Vec<u8>>, HostApiError>

读取插件本地缓存;缓存不存在时返回 Ok(None)。

Source

pub async fn cache_delete( &self, domain: &str, key: &str, ) -> Result<(), HostApiError>

删除插件本地缓存条目;缓存不存在时视为成功。

Source

pub async fn cache_cleanup( &self, domain: &str, max_entries: usize, ) -> Result<(), HostApiError>

容量控制:缓存域条目超过 max_entries 时按修改时间删除最旧条目。

Source

pub fn register_hotkey_callback( &self, id: &str, filter: HotkeyEventFilter, callback: HotkeyCallback, )

注册按键事件回调。ID 自动前缀化为 “{plugin_id}:{id}”。

Source

pub fn unregister_hotkey_callback(&self, id: &str)

注销按键事件回调。

Source

pub fn register_installation_callback( &self, id: &str, callback: InstallationCallback, )

注册安装事件回调。ID 自动前缀化为 “{plugin_id}:{id}”。

Source

pub fn unregister_installation_callback(&self, id: &str)

注销安装事件回调。

Source

pub fn register_focus_callback(&self, id: &str, callback: FocusCallback)

注册焦点事件回调。ID 自动前缀化为 “{plugin_id}:{id}”。

Source

pub fn unregister_focus_callback(&self, id: &str)

注销焦点事件回调。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the bradford method by default.
Source§

impl<T, C> AdaptIntoUnclamped<T> for C
where T: AdaptFromUnclamped<C>,

Source§

type Scalar = <T as AdaptFromUnclamped<C>>::Scalar

The number type that’s used as the color’s components.
Source§

fn adapt_into_unclamped_with<M>(self) -> T

Adapt a color of type Self into a color of type T, using the custom matrix M. Read more
Source§

fn adapt_into_unclamped(self) -> T
where Bradford: LmsToXyz<Self::Scalar> + XyzToLms<Self::Scalar>,

Adapt a color of type Self into a color of type T, using the Bradford matrix. Read more
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, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

impl<T, C> ComponentsInto<C> for T

Source§

fn components_into(self) -> C

Cast this collection of color components into a collection of colors. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. Read more
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.
Source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more