pub trait Configurable: Send + Sync {
Show 18 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 runtime_state(&self) -> Option<Value> { ... }
fn restore_runtime_state(&self, state: 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§
Sourcefn core(&self) -> &ComponentCore
fn core(&self) -> &ComponentCore
返回组件身份核心。
实现者只需提供对 ComponentCore 的引用,identity 相关方法即可使用默认实现。
Sourcefn setting_schema(&self) -> Vec<SettingDefinition>
fn setting_schema(&self) -> Vec<SettingDefinition>
返回组件的设置项 schema 定义列表。
组件实现者在此方法中通过 SchemaBuilder 声明所有配置字段。
默认返回空列表。
Provided Methods§
fn component_id(&self) -> &str
fn component_name(&self) -> &str
fn component_type(&self) -> ComponentType
Sourcefn component_description(&self) -> &str
fn component_description(&self) -> &str
组件的功能描述文本,用于设置面板中向用户解释该组件的用途。
Sourcefn settings_contribution(&self) -> Result<SettingsContribution, ConfigError>
fn settings_contribution(&self) -> Result<SettingsContribution, ConfigError>
将 setting_schema() 的输出编译为 SettingsContribution。
内含 schema 校验(重复 key、UI pointer 一致性、约束合法性等)。
默认实现调用 SettingsContribution::from_entries()。
Sourcefn get_settings(&self) -> Value
fn get_settings(&self) -> Value
获取组件当前的配置值(JSON 格式)。
Sourcefn 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 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 下发配置到插件进程。
Sourcefn 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 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 委托插件进程补充业务校验。
fn get_default_settings(&self) -> Value
Sourcefn runtime_state(&self) -> Option<Value>
fn runtime_state(&self) -> Option<Value>
返回组件运行态快照(非用户配置:不写入 settings、不下发前端、不参与远端配置同步)。
适用于需要在重启后延续统计/状态的宿主内置组件(写入独立的运行态文件)。
默认 None 表示该组件无运行态需要持久化;第三方插件组件(远端进程)不参与
本通道——它们经 SDK 的 resource_* / cache_* / ZEROLAUNCH_DATA_DIR 自行持久化。
Sourcefn restore_runtime_state(&self, state: Value)
fn restore_runtime_state(&self, state: Value)
从持久化的运行态恢复组件内部状态。
由 ConfigManager 在 load_from_storage 内对当时已注册的组件调用一次
(内置组件在 Phase A 注册,故恢复先于搜索管道构建);配置加载之后才注册的
组件(第三方插件组件)不经过本方法。默认空实现。
fn on_settings_changed(&self)
Sourcefn config_actions(&self) -> Vec<ConfigActionDef>
fn config_actions(&self) -> Vec<ConfigActionDef>
返回该组件支持的配置动作定义列表。 配置动作用于在设置面板中提供一键式辅助操作(如自动检测浏览器), 前端据此渲染操作按钮,用户点击后通过 execute_config_action 执行。
Sourcefn 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 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 格式),由前端根据配置项类型解析并填充。
Sourcefn default_enabled(&self) -> bool
fn default_enabled(&self) -> bool
返回组件的默认启用状态。 某些组件可能默认禁用(如实验性功能)。 实际启用状态由 ConfigManager 管理,用户设置会覆盖此默认值。
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".