mirror of
https://github.com/apple/swift-http-types
synced 2026-11-29 05:14:22 +00:00
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:
1 parent
0fd14cc0fc
commit
db774a277f
10 files changed
+89
-27
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user