open_lark/core/trait_system/
macros.rs1#[macro_export]
29macro_rules! impl_executable_builder {
30 (
31 $builder:ty,
32 $service:ty,
33 $request:ty,
34 $response:ty,
35 $method:ident
36 ) => {
37 #[async_trait::async_trait]
38 impl $crate::core::trait_system::ExecutableBuilder<$service, $request, $response>
39 for $builder
40 {
41 fn build(self) -> $request {
42 self.build()
43 }
44
45 async fn execute(self, service: &$service) -> $crate::core::SDKResult<$response> {
46 service.$method(&self.build(), None).await
47 }
48
49 async fn execute_with_options(
50 self,
51 service: &$service,
52 option: $crate::core::req_option::RequestOption,
53 ) -> $crate::core::SDKResult<$response> {
54 service.$method(&self.build(), Some(option)).await
55 }
56 }
57 };
58}
59
60#[macro_export]
64macro_rules! impl_executable_builder_owned {
65 (
66 $builder:ty,
67 $service:ty,
68 $request:ty,
69 $response:ty,
70 $method:ident
71 ) => {
72 #[async_trait::async_trait]
73 impl $crate::core::trait_system::ExecutableBuilder<$service, $request, $response>
74 for $builder
75 {
76 fn build(self) -> $request {
77 self.build()
78 }
79
80 async fn execute(self, service: &$service) -> $crate::core::SDKResult<$response> {
81 service.$method(self.build(), None).await
82 }
83
84 async fn execute_with_options(
85 self,
86 service: &$service,
87 option: $crate::core::req_option::RequestOption,
88 ) -> $crate::core::SDKResult<$response> {
89 service.$method(self.build(), Some(option)).await
90 }
91 }
92 };
93}
94
95#[macro_export]
99macro_rules! impl_executable_builder_config {
100 (
101 $builder:ty,
102 $request:ty,
103 $response:ty,
104 $function:ident
105 ) => {
106 impl $builder {
107 pub async fn execute(
109 self,
110 config: &$crate::core::config::Config,
111 ) -> $crate::core::SDKResult<$response> {
112 $function(self.build(), config, None).await
113 }
114
115 pub async fn execute_with_options(
117 self,
118 config: &$crate::core::config::Config,
119 option: $crate::core::req_option::RequestOption,
120 ) -> $crate::core::SDKResult<$response> {
121 $function(self.build(), config, Some(option)).await
122 }
123 }
124 };
125}