open_lark/core/trait_system/
executable_builder.rs

1/// ExecutableBuilder trait - 统一的Builder执行接口
2///
3/// 这个trait为所有Builder提供了统一的execute方法接口,
4/// 消除了手动实现重复execute方法的需要。
5///
6/// # 类型参数
7/// - `TService`: 服务类型
8/// - `TRequest`: 请求类型  
9/// - `TResponse`: 响应类型
10///
11/// # 方法
12/// - `build()`: 构建请求对象
13/// - `execute()`: 执行请求
14/// - `execute_with_options()`: 带选项执行请求
15use async_trait::async_trait;
16
17#[async_trait]
18pub trait ExecutableBuilder<TService, TRequest, TResponse>
19where
20    TService: Send + Sync,
21    TRequest: Send + Sync,
22    TResponse: Send + Sync,
23{
24    /// 构建请求对象
25    fn build(self) -> TRequest;
26
27    /// 执行请求并返回响应
28    async fn execute(self, service: &TService) -> crate::core::SDKResult<TResponse>
29    where
30        Self: Sized;
31
32    /// 带选项执行请求
33    async fn execute_with_options(
34        self,
35        service: &TService,
36        option: crate::core::req_option::RequestOption,
37    ) -> crate::core::SDKResult<TResponse>
38    where
39        Self: Sized;
40}