Skip to main content

Configurable

Trait Configurable 

Source
pub trait Configurable: Send + Sync {
Show 16 methods // Required methods fn core(&self) -> &ComponentCore; fn setting_schema(&self) -> Vec<SettingDefinition>; // Provided methods fn component_id(&self) -> &str { ... } fn component_name(&self) -> &str { ... } fn component_type(&self) -> ComponentType { ... } fn priority(&self) -> u32 { ... } fn component_description(&self) -> &str { ... } fn settings_contribution(&self) -> Result<SettingsContribution, ConfigError> { ... } fn get_settings(&self) -> Value { ... } fn apply_settings<'life0, 'async_trait>( &'life0 self, settings: Value, ) -> Pin<Box<dyn Future<Output = Result<(), ConfigError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn validate_settings<'life0, 'life1, 'async_trait>( &'life0 self, settings: &'life1 Value, ) -> Pin<Box<dyn Future<Output = Result<(), ConfigError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn get_default_settings(&self) -> Value { ... } fn on_settings_changed(&self) { ... } fn config_actions(&self) -> Vec<ConfigActionDef> { ... } fn execute_config_action<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, action: &'life1 str, params: &'life2 Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait { ... } fn default_enabled(&self) -> bool { ... }
}
Expand description

所有可配置组件都需实现的核心契约。

提供组件标识、配置定义、配置读写和配置变更回调能力。

Required Methods§

Source

fn core(&self) -> &ComponentCore

返回组件身份核心。

实现者只需提供对 ComponentCore 的引用,identity 相关方法即可使用默认实现。

Source

fn setting_schema(&self) -> Vec<SettingDefinition>

返回组件的设置项 schema 定义列表。

组件实现者在此方法中通过 SchemaBuilder 声明所有配置字段。 默认返回空列表。

Provided Methods§

Source

fn component_id(&self) -> &str

Source

fn component_name(&self) -> &str

Source

fn component_type(&self) -> ComponentType

Source

fn priority(&self) -> u32

组件显示排序优先级,数值越小越靠前。

Source

fn component_description(&self) -> &str

组件的功能描述文本,用于设置面板中向用户解释该组件的用途。

Source

fn settings_contribution(&self) -> Result<SettingsContribution, ConfigError>

将 setting_schema() 的输出编译为 SettingsContribution。

内含 schema 校验(重复 key、UI pointer 一致性、约束合法性等)。 默认实现调用 SettingsContribution::from_entries()。

Source

fn get_settings(&self) -> Value

获取组件当前的配置值(JSON 格式)。

Source

fn apply_settings<'life0, 'async_trait>( &'life0 self, settings: Value, ) -> Pin<Box<dyn Future<Output = Result<(), ConfigError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

应用配置到组件。 使用 &self 签名,组件内部通过 RwLock 等实现可变性。 async:远端插件(RemoteComponent)实现需经 RPC 下发配置到插件进程。

Source

fn validate_settings<'life0, 'life1, 'async_trait>( &'life0 self, settings: &'life1 Value, ) -> Pin<Box<dyn Future<Output = Result<(), ConfigError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

校验一组配置值是否合法(不会实际应用)。 async:远端插件实现需经 RPC 委托插件进程补充业务校验。

Source

fn get_default_settings(&self) -> Value

Source

fn on_settings_changed(&self)

Source

fn config_actions(&self) -> Vec<ConfigActionDef>

返回该组件支持的配置动作定义列表。 配置动作用于在设置面板中提供一键式辅助操作(如自动检测浏览器), 前端据此渲染操作按钮,用户点击后通过 execute_config_action 执行。

Source

fn execute_config_action<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, action: &'life1 str, params: &'life2 Value, ) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

执行配置动作。 参数:action - 动作标识符,对应 ConfigActionDef.action。 params - 前端传递的附加参数(如书签文件路径)。 返回:动作执行结果(JSON 格式),由前端根据配置项类型解析并填充。

Source

fn default_enabled(&self) -> bool

返回组件的默认启用状态。 某些组件可能默认禁用(如实验性功能)。 实际启用状态由 ConfigManager 管理,用户设置会覆盖此默认值。

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§