Add support for Display String type to StructuredFieldValues (#51)

Motivation:

The parser and serializer for the Display String type have been
implemented. The high-level encoder and decoder should follow.

Modifications:

Implement the encoder and decoder for Display String.

Result:

The StructuredFieldValues module will support the Display String type.

---------

Co-authored-by: Cory Benfield <lukasa@apple.com>
This commit is contained in:
Clinton NkwochaandCory Benfield authored and GitHub committed 2024-12-10 07:56:51 +00:00
1 parent 0d92bf6b08
commit be84570e9f
13 files changed
+292 -43

No files matched your search

@@ -111,16 +111,20 @@ extension StructuredFieldValueDecoder {
// An escape hatch here for top-level data: if we don't do this, it'll ask for
// an unkeyed container and get very confused.
if type is Data.Type {
switch type {
case is Data.Type:
let container = try decoder.singleValueContainer()
return try container.decode(Data.self) as! StructuredField
} else if type is Decimal.Type {
case is Decimal.Type:
let container = try decoder.singleValueContainer()
return try container.decode(Decimal.self) as! StructuredField
} else if type is Date.Type {
case is Date.Type:
let container = try decoder.singleValueContainer()
return try container.decode(Date.self) as! StructuredField
} else {
case is DisplayString.Type:
let container = try decoder.singleValueContainer()
return try container.decode(DisplayString.self) as! StructuredField
default:
return try type.init(from: decoder)
}
}