Support embedded Swift (#116)

In order for swift-http-api-proposal to support embedded Swift,
swift-http-types has to support embedded Swift first.
This commit is contained in:
Guoye Zhang authored and GitHub committed 2026-06-05 10:54:44 -07:00
1 parent 0fd14cc0fc
commit db774a277f
10 files changed
+89 -27

No files matched your search

+7 -3
View File
@@ -112,9 +112,9 @@ public struct HTTPField: Sendable, Hashable {
///
/// - Parameter body: The closure to be invoked with the buffer.
/// - Returns: Result of the `body` closure.
public func withUnsafeBytesOfValue<Result>(
_ body: (UnsafeBufferPointer<UInt8>) throws -> Result
) rethrows -> Result {
public func withUnsafeBytesOfValue<Result, Failure: Error>(
_ body: (UnsafeBufferPointer<UInt8>) throws(Failure) -> Result
) throws(Failure) -> Result {
try self.rawValue.withUnsafeBytes(body)
}
@@ -219,6 +219,8 @@ extension HTTPField: CustomStringConvertible {
}
}
#if !hasFeature(Embedded)
extension HTTPField: CustomPlaygroundDisplayConvertible {
public var playgroundDescription: Any {
self.description
@@ -261,6 +263,8 @@ extension HTTPField: Codable {
}
}
#endif
extension HTTPField {
static func isValidToken(_ token: some StringProtocol) -> Bool {
!token.isEmpty