|
86 | 86 | ) |
87 | 87 | } |
88 | 88 |
|
89 | | - /// Create a array decoder and encoder based on provided data. |
| 89 | + /// Create an array decoder and encoder based on provided data. |
90 | 90 | /// |
91 | 91 | /// By default, no additional customizations configuration is used. |
92 | 92 | /// |
@@ -163,3 +163,75 @@ where |
163 | 163 | } |
164 | 164 | } |
165 | 165 | } |
| 166 | + |
| 167 | +extension SequenceCoder { |
| 168 | + /// Create a sequence decoder and encoder based on provided data. |
| 169 | + /// |
| 170 | + /// - Parameters: |
| 171 | + /// - output: The resulting sequence type. |
| 172 | + /// - elementHelperCreation: The `HelperCoder` creation function. |
| 173 | + /// - configuration: The configuration for decoding and encoding. |
| 174 | + /// - properties: Values that can be passed to creation function. |
| 175 | + public init<each Property>( |
| 176 | + output: Sequence.Type, |
| 177 | + elementHelperCreation: (repeat each Property) -> ElementHelper, |
| 178 | + configuration: Configuration, |
| 179 | + properties: repeat each Property |
| 180 | + ) { |
| 181 | + self.init( |
| 182 | + output: output, |
| 183 | + elementHelper: elementHelperCreation(repeat each properties), |
| 184 | + configuration: configuration |
| 185 | + ) |
| 186 | + } |
| 187 | + |
| 188 | + /// Create an array decoder and encoder based on provided data. |
| 189 | + /// |
| 190 | + /// - Parameters: |
| 191 | + /// - elementHelperCreation: The `HelperCoder` creation function. |
| 192 | + /// - configuration: The configuration for decoding and encoding. |
| 193 | + /// - properties: Values that can be passed to creation function. |
| 194 | + public init<each Property>( |
| 195 | + elementHelperCreation: (repeat each Property) -> ElementHelper, |
| 196 | + configuration: Configuration, |
| 197 | + properties: repeat each Property |
| 198 | + ) where Sequence == Array<ElementHelper.Coded> { |
| 199 | + #if swift(>=5.10) |
| 200 | + self.init( |
| 201 | + output: Sequence.self, elementHelperCreation: elementHelperCreation, |
| 202 | + configuration: configuration, properties: repeat each properties |
| 203 | + ) |
| 204 | + #else |
| 205 | + self.init( |
| 206 | + output: Sequence.self, |
| 207 | + elementHelper: elementHelperCreation(repeat each properties), |
| 208 | + configuration: configuration |
| 209 | + ) |
| 210 | + #endif |
| 211 | + } |
| 212 | + |
| 213 | + /// Create an array decoder and encoder based on provided data. |
| 214 | + /// |
| 215 | + /// By default, no additional customizations configuration is used. |
| 216 | + /// |
| 217 | + /// - Parameters: |
| 218 | + /// - elementHelperCreation: The `HelperCoder` creation function. |
| 219 | + /// - properties: Values that can be passed to creation function. |
| 220 | + public init<each Property>( |
| 221 | + elementHelperCreation: (repeat each Property) -> ElementHelper, |
| 222 | + properties: repeat each Property |
| 223 | + ) where Sequence == Array<ElementHelper.Coded> { |
| 224 | + #if swift(>=5.10) |
| 225 | + self.init( |
| 226 | + elementHelperCreation: elementHelperCreation, |
| 227 | + configuration: .init(), properties: repeat each properties |
| 228 | + ) |
| 229 | + #else |
| 230 | + self.init( |
| 231 | + output: Sequence.self, |
| 232 | + elementHelper: elementHelperCreation(repeat each properties), |
| 233 | + configuration: .init() |
| 234 | + ) |
| 235 | + #endif |
| 236 | + } |
| 237 | +} |
0 commit comments