mirror of
https://github.com/apple/swift-http-structured-headers
synced 2026-11-24 04:37:50 +00:00
Rename a number of types and modules. (#13)
Motivation: In general we should try to be specific about what we're referring to. "Structured headers" is not really an accurate description of what this module works with: "Structured Header Field Values", or "Structured Field Value" is usually better. To that end this change adjusts our naming to be closer to what we want. It also changes our module names to prioritise the use of the Codable-based one. Modifications: - Renamed CodableStructuredHeaders to StructuredFieldValues. - Renamed StructuredHeaders to RawStructuredFieldValues. - Renamed a number of types from Field to FieldValue. - Renamed a number of types from Header to Field or FieldValue. - Renamed some functions along the above lines. Result: Better and more consistent terminology will be used.
This commit is contained in:
1 parent
f881e6c41b
commit
27e163f96a
31 files changed
+313
-313
No files matched your search
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This source file is part of the SwiftNIO open source project
|
||||
//
|
||||
// Copyright (c) 2020-2021 Apple Inc. and the SwiftNIO project authors
|
||||
// Licensed under Apache License v2.0
|
||||
//
|
||||
// See LICENSE.txt for license information
|
||||
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
import RawStructuredFieldValues
|
||||
|
||||
struct _StructuredHeaderCodingKey: CodingKey {
|
||||
var stringValue: String
|
||||
var intValue: Int?
|
||||
|
||||
init(stringValue: String) {
|
||||
self.stringValue = stringValue
|
||||
self.intValue = nil
|
||||
}
|
||||
|
||||
init(intValue: Int) {
|
||||
self.stringValue = "\(intValue)"
|
||||
self.intValue = intValue
|
||||
}
|
||||
|
||||
init<Key: CodingKey>(_ key: Key, keyDecodingStrategy: StructuredFieldValueDecoder.KeyDecodingStrategy?) {
|
||||
switch keyDecodingStrategy {
|
||||
case .none:
|
||||
self.stringValue = key.stringValue
|
||||
case .some(.lowercase):
|
||||
self.stringValue = key.stringValue.lowercased()
|
||||
default:
|
||||
preconditionFailure("Invalid key decoding strategy")
|
||||
}
|
||||
|
||||
self.intValue = key.intValue
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user