@@ -93,3 +93,86 @@ public extension Module {
93
93
try forward ( inputs)
94
94
}
95
95
}
96
+
97
+ @available ( * , deprecated, message: " This API is experimental. " )
98
+ public extension Module {
99
+ /// Executes a specific method and decodes the outputs into `Output` generic type.
100
+ ///
101
+ /// - Parameters:
102
+ /// - method: The name of the method to execute.
103
+ /// - inputs: An array of `ValueConvertible` inputs.
104
+ /// - Returns: An instance of `Output` decoded from the returned `[Value]`, or `nil` on mismatch.
105
+ /// - Throws: An error if loading, execution or result conversion fails.
106
+ func execute< Output: ValueSequenceConstructible > ( _ method: String , _ inputs: [ ValueConvertible ] ) throws -> Output {
107
+ try Output ( __executeMethod ( method, withInputs: inputs. map { $0. asValue ( ) } ) )
108
+ }
109
+
110
+ /// Executes a specific method with variadic inputs and decodes into `Output` generic type.
111
+ ///
112
+ /// - Parameters:
113
+ /// - method: The name of the method to execute.
114
+ /// - inputs: A variadic list of `ValueConvertible` inputs.
115
+ /// - Returns: An instance of `Output` decoded from the returned `[Value]`, or `nil` on mismatch.
116
+ /// - Throws: An error if loading, execution or result conversion fails.
117
+ func execute< Output: ValueSequenceConstructible > ( _ method: String , _ inputs: ValueConvertible ... ) throws -> Output {
118
+ try execute ( method, inputs)
119
+ }
120
+
121
+ /// Executes a specific method with a single input and decodes into `Output` generic type.
122
+ ///
123
+ /// - Parameters:
124
+ /// - method: The name of the method to execute.
125
+ /// - input: A single `ValueConvertible` input.
126
+ /// - Returns: An instance of `Output` decoded from the returned `[Value]`, or `nil` on mismatch.
127
+ /// - Throws: An error if loading, execution or result conversion fails.
128
+ func execute< Output: ValueSequenceConstructible > ( _ method: String , _ input: ValueConvertible ) throws -> Output {
129
+ try execute ( method, [ input] )
130
+ }
131
+
132
+ /// Executes a specific method with no inputs and decodes into `Output` generic type.
133
+ ///
134
+ /// - Parameter method: The name of the method to execute.
135
+ /// - Returns: An instance of `Output` decoded from the returned `[Value]`, or `nil` on mismatch.
136
+ /// - Throws: An error if loading, execution or result conversion fails.
137
+ func execute< Output: ValueSequenceConstructible > ( _ method: String ) throws -> Output {
138
+ try execute ( method, [ ] )
139
+ }
140
+
141
+ /// Executes the "forward" method and decodes into `Output` generic type.
142
+ ///
143
+ /// - Parameters:
144
+ /// - inputs: An array of `ValueConvertible` inputs to pass to "forward".
145
+ /// - Returns: An instance of `Output` decoded from the returned `[Value]`, or `nil` on mismatch.
146
+ /// - Throws: An error if loading, execution or result conversion fails.
147
+ func forward< Output: ValueSequenceConstructible > ( _ inputs: [ ValueConvertible ] ) throws -> Output {
148
+ try execute ( " forward " , inputs)
149
+ }
150
+
151
+ /// Executes the "forward" method with variadic inputs and decodes into `Output` generic type.
152
+ ///
153
+ /// - Parameters:
154
+ /// - inputs: A variadic list of `ValueConvertible` inputs.
155
+ /// - Returns: An instance of `Output` decoded from the returned `[Value]`, or `nil` on mismatch.
156
+ /// - Throws: An error if loading, execution or result conversion fails.
157
+ func forward< Output: ValueSequenceConstructible > ( _ inputs: ValueConvertible ... ) throws -> Output {
158
+ try forward ( inputs)
159
+ }
160
+
161
+ /// Executes the "forward" method with a single input and decodes into `Output` generic type.
162
+ ///
163
+ /// - Parameters:
164
+ /// - input: A single `ValueConvertible` to pass to "forward".
165
+ /// - Returns: An instance of `Output` decoded from the returned `[Value]`, or `nil` on mismatch.
166
+ /// - Throws: An error if loading, execution or result conversion fails.
167
+ func forward< Output: ValueSequenceConstructible > ( _ input: ValueConvertible ) throws -> Output {
168
+ try forward ( [ input] )
169
+ }
170
+
171
+ /// Executes the "forward" method with no inputs and decodes into `Output` generic type.
172
+ ///
173
+ /// - Returns: An instance of `Output` decoded from the returned `[Value]`, or `nil` on mismatch.
174
+ /// - Throws: An error if loading, execution or result conversion fails.
175
+ func forward< Output: ValueSequenceConstructible > ( ) throws -> Output {
176
+ try execute ( " forward " )
177
+ }
178
+ }
0 commit comments