in Sources/StructuredFieldValues/Decoder/BareInnerListDecoder.swift [53:78]
mutating func decode<T>(_ type: T.Type) throws -> T where T: Decodable {
// This is a request to decode a scalar. We decode the next entry and increment the index.
guard !self.isAtEnd else {
throw StructuredHeaderError.indexOutOfRange
}
let codingKey = _StructuredHeaderCodingKey(intValue: self.currentOffset)
defer {
self.currentOffset += 1
}
try self.decoder.push(codingKey)
defer {
self.decoder.pop()
}
if type is Data.Type {
let container = try self.decoder.singleValueContainer()
return try container.decode(Data.self) as! T
} else if type is Decimal.Type {
let container = try self.decoder.singleValueContainer()
return try container.decode(Decimal.self) as! T
} else {
return try type.init(from: self.decoder)
}
}