You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -229,13 +229,79 @@ Library provides following helpers that address common custom decoding/encoding
229
229
- Custom Date decoding/encoding with UNIX timestamp (`Since1970DateCoder`) or date formatters (`DateCoder`, `ISO8601DateCoder`).
230
230
-`Base64Coder` to decode/encode data in base64 string representation.
231
231
232
-
And more, see the full documentation for [`HelperCoders`](https://swiftpackageindex.com/SwiftyLab/MetaCodable/main/documentation/helpercoders) for more details.
232
+
And more, see the full documentation for [`HelperCoders`](https://swiftpackageindex.com/SwiftyLab/MetaCodable/documentation/helpercoders) for more details.
233
233
234
234
You can even create your own by conforming to `HelperCoder`.
235
235
236
236
</details>
237
237
238
-
See the full documentation for [`MetaCodable`](https://swiftpackageindex.com/SwiftyLab/MetaCodable/main/documentation/metacodable) and [`HelperCoders`](https://swiftpackageindex.com/SwiftyLab/MetaCodable/main/documentation/helpercoders), for API details and advanced use cases.
238
+
<details>
239
+
<summary>Represent data with variations in the form of external/internal/adjacent tagging, with single enum with each case as a variation.</summary>
240
+
241
+
i.e. while `Swift` compiler only generates implementation assuming external tagged enums, only following data:
242
+
243
+
```json
244
+
[
245
+
{
246
+
"load": {
247
+
"key": "MyKey"
248
+
}
249
+
},
250
+
{
251
+
"store": {
252
+
"key": "MyKey",
253
+
"value": 42
254
+
}
255
+
}
256
+
]
257
+
```
258
+
259
+
can be represented by following `enum` with current compiler implementation:
260
+
261
+
```swift
262
+
enumCommand {
263
+
caseload(key: String)
264
+
casestore(key: String, value: Int)
265
+
}
266
+
```
267
+
268
+
while `MetaCodable` allows data in both of the following format to be represented by above `enum` as well:
269
+
270
+
```json
271
+
[
272
+
{
273
+
"type": "load",
274
+
"key": "MyKey"
275
+
},
276
+
{
277
+
"type": "store",
278
+
"key": "MyKey",
279
+
"value": 42
280
+
}
281
+
]
282
+
```
283
+
284
+
```json
285
+
[
286
+
{
287
+
"type": "load",
288
+
"content": {
289
+
"key": "MyKey"
290
+
}
291
+
},
292
+
{
293
+
"type": "store",
294
+
"content": {
295
+
"key": "MyKey",
296
+
"value": 42
297
+
}
298
+
}
299
+
]
300
+
```
301
+
302
+
</details>
303
+
304
+
See the full documentation for [`MetaCodable`](https://swiftpackageindex.com/SwiftyLab/MetaCodable/documentation/metacodable) and [`HelperCoders`](https://swiftpackageindex.com/SwiftyLab/MetaCodable/documentation/helpercoders), for API details and advanced use cases.
239
305
Also, [see the limitations](Sources/MetaCodable/MetaCodable.docc/Limitations.md).
Copy file name to clipboardExpand all lines: Sources/MetaCodable/MetaCodable.docc/Limitations.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Currently all the limitations of this library and possible workarounds and futur
8
8
9
9
### Why strict typing is necessary?
10
10
11
-
`Swift` doesn't provide any type inference data, so to know type of variables ``Codable()`` needs types to be explicitly specified in the code. i.e. following code will not work and will cause error while macro expansion:
11
+
`Swift`compiler doesn't provide any type inference data to macros, so to know type of variables ``Codable()`` needs types to be explicitly specified in the code. i.e. following code will not work and will cause error while macro expansion:
12
12
13
13
```swift
14
14
@Codable
@@ -61,6 +61,10 @@ enum SomeEnum {
61
61
}
62
62
```
63
63
64
+
### Why `enum`s with raw value aren't supported?
65
+
66
+
`Swift` compiler by default generates `Codable` conformance for `enum`s with raw value and `MetaCodable` has nothing extra to add for these type of `enum`s. Hence, in this case the default compiler generated implementation can be used.
67
+
64
68
### Why `actor` conformance to `Encodable` not generated?
65
69
66
70
For `actor`s ``Codable()`` generates `Decodable` conformance, while `Encodable` conformance isn't generated, only `encode(to:)` method implementation is generated which is isolated to `actor`.
0 commit comments