Skip to content

Commit

Permalink
some AsyncChunkedSequence<UInt8>
Browse files Browse the repository at this point in the history
  • Loading branch information
swhitty committed Jun 8, 2024
1 parent b3f2ed1 commit 53ee852
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions FlyingFox/Sources/HTTPDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import Foundation

struct HTTPDecoder {

static func decodeRequest<S>(from bytes: S) async throws -> HTTPRequest where S: AsyncChunkedSequence, S.Element == UInt8 {
static func decodeRequest(from bytes: some AsyncChunkedSequence<UInt8>) async throws -> HTTPRequest {
let status = try await bytes.lines.takeNext()
let comps = status
.trimmingCharacters(in: .whitespacesAndNewlines)
Expand All @@ -60,7 +60,7 @@ struct HTTPDecoder {
)
}

static func decodeResponse<S>(from bytes: S) async throws -> HTTPResponse where S: AsyncChunkedSequence, S.Element == UInt8 {
static func decodeResponse(from bytes: some AsyncChunkedSequence<UInt8>) async throws -> HTTPResponse {
let comps = try await bytes.lines.takeNext()
.trimmingCharacters(in: .whitespacesAndNewlines)
.split(separator: " ", maxSplits: 2, omittingEmptySubsequences: true)
Expand Down
6 changes: 3 additions & 3 deletions FlyingFox/Sources/WebSocket/WSFrameEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct WSFrameEncoder {
}
}

static func decodePayload<S>(from bytes: S, length: Int, mask: WSFrame.Mask?) async throws -> Data where S: AsyncChunkedSequence, S.Element == UInt8 {
static func decodePayload(from bytes: some AsyncChunkedSequence<UInt8>, length: Int, mask: WSFrame.Mask?) async throws -> Data {
var iterator = bytes.makeAsyncIterator()
guard var payload = try await iterator.nextChunk(count: length) else {
throw SocketError.disconnected
Expand All @@ -130,7 +130,7 @@ struct WSFrameEncoder {
return Data(payload)
}

static func decodeLengthMask<S>(from bytes: S) async throws -> (length: Int, mask: WSFrame.Mask?) where S: AsyncChunkedSequence, S.Element == UInt8 {
static func decodeLengthMask(from bytes: some AsyncChunkedSequence<UInt8>) async throws -> (length: Int, mask: WSFrame.Mask?) {
let byte0 = try await bytes.take()
let hasMask = byte0 & 0b10000000 == 0b10000000
let length0 = byte0 & 0b01111111
Expand Down Expand Up @@ -158,7 +158,7 @@ struct WSFrameEncoder {
}
}

static func decodeMask<S>(from bytes: S) async throws -> WSFrame.Mask where S: AsyncChunkedSequence, S.Element == UInt8 {
static func decodeMask(from bytes: some AsyncChunkedSequence<UInt8>) async throws -> WSFrame.Mask {
try await WSFrame.Mask(m1: bytes.take(),
m2: bytes.take(),
m3: bytes.take(),
Expand Down

0 comments on commit 53ee852

Please sign in to comment.