pub trait ParameterResolver: Send + Sync {
// Required methods
fn resolve<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
template: &'life1 str,
user_args: &'life2 [String],
snapshot: &'life3 ParameterSnapshot,
) -> Pin<Box<dyn Future<Output = Result<String, ParameterError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn count_user_parameters(&self, template: &str) -> usize;
fn has_system_parameters(&self, template: &str) -> bool;
}Expand description
参数解析器 trait
通过 PluginHandle 暴露给插件和 Executor 使用。 设计说明:
- resolve 方法为异步接口,保持与其他 SDK trait 风格统一
- count_user_parameters 和 has_system_parameters 为同步方法,因为它们只是纯字符串解析
Required Methods§
Sourcefn resolve<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
template: &'life1 str,
user_args: &'life2 [String],
snapshot: &'life3 ParameterSnapshot,
) -> Pin<Box<dyn Future<Output = Result<String, ParameterError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn resolve<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
template: &'life1 str,
user_args: &'life2 [String],
snapshot: &'life3 ParameterSnapshot,
) -> Pin<Box<dyn Future<Output = Result<String, ParameterError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
解析模板,填充参数
参数:
- template: 包含占位符的模板字符串(如 “notepad {clip}”)
- user_args: 用户输入的参数列表
- snapshot: 系统参数快照(不透明句柄,由 capture_parameter_snapshot() 返回)
返回:填充后的完整字符串
Sourcefn count_user_parameters(&self, template: &str) -> usize
fn count_user_parameters(&self, template: &str) -> usize
统计模板中需要用户输入的参数数量(同步方法,纯计算)
Sourcefn has_system_parameters(&self, template: &str) -> bool
fn has_system_parameters(&self, template: &str) -> bool
检查模板是否包含系统参数(同步方法,纯计算)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".