mirror of
https://github.com/apple/swift-http-structured-headers
synced 2026-11-24 04:37:50 +00:00
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:
1 parent
0d92bf6b08
commit
be84570e9f
13 files changed
+292
-43
No files matched your search
@@ -54,16 +54,20 @@ extension KeyedInnerListDecoder: KeyedDecodingContainerProtocol {
|
||||
self.decoder.pop()
|
||||
}
|
||||
|
||||
if type is Data.Type {
|
||||
switch type {
|
||||
case is Data.Type:
|
||||
let container = try self.decoder.singleValueContainer()
|
||||
return try container.decode(Data.self) as! T
|
||||
} else if type is Decimal.Type {
|
||||
case is Decimal.Type:
|
||||
let container = try self.decoder.singleValueContainer()
|
||||
return try container.decode(Decimal.self) as! T
|
||||
} else if type is Date.Type {
|
||||
case is Date.Type:
|
||||
let container = try self.decoder.singleValueContainer()
|
||||
return try container.decode(Date.self) as! T
|
||||
} else {
|
||||
case is DisplayString.Type:
|
||||
let container = try self.decoder.singleValueContainer()
|
||||
return try container.decode(DisplayString.self) as! T
|
||||
default:
|
||||
return try type.init(from: self.decoder)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user