Skip to content

Commit ea36d7a

Browse files
committed
some AsyncChunkedSequence
1 parent 172219b commit ea36d7a

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

FlyingFox/Sources/HTTPBodySequence.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public struct HTTPBodySequence: Sendable, AsyncSequence {
4646
self.storage = .complete(data)
4747
}
4848

49-
public init<S: AsyncChunkedSequence>(from bytes: S, count: Int) where S.Element == UInt8 {
49+
public init(from bytes: some AsyncChunkedSequence<UInt8>, count: Int) {
5050
self.storage = .sequence(
5151
AsyncDataSequence(from: bytes, count: count, chunkSize: 4096)
5252
)
@@ -56,7 +56,7 @@ public struct HTTPBodySequence: Sendable, AsyncSequence {
5656
try self.init(file: url, chunkSize: 4096)
5757
}
5858

59-
init<S: AsyncChunkedSequence>(from bytes: S, count: Int, chunkSize: Int) where S.Element == UInt8 {
59+
init(from bytes: some AsyncChunkedSequence<UInt8>, count: Int, chunkSize: Int) {
6060
self.storage = .sequence(
6161
AsyncDataSequence(from: bytes, count: count, chunkSize: chunkSize)
6262
)

FlyingFox/Sources/HTTPDecoder.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ struct HTTPDecoder {
104104
return (HTTPHeader(name), value)
105105
}
106106

107-
static func readHeaders<S: AsyncChunkedSequence>(from bytes: S) async throws -> [HTTPHeader : String] where S.Element == UInt8 {
107+
static func readHeaders(from bytes: some AsyncChunkedSequence<UInt8>) async throws -> [HTTPHeader : String] {
108108
try await bytes
109109
.lines
110110
.prefix { $0 != "\r" && $0 != "" }
111111
.compactMap(Self.readHeader)
112112
.reduce(into: [HTTPHeader: String]()) { $0[$1.header] = $1.value }
113113
}
114114

115-
static func readBody<S: AsyncChunkedSequence>(from bytes: S, length: String?, maxSizeForComplete: Int = 10_485_760) async throws -> HTTPBodySequence where S.Element == UInt8 {
115+
static func readBody(from bytes: some AsyncChunkedSequence<UInt8>, length: String?, maxSizeForComplete: Int = 10_485_760) async throws -> HTTPBodySequence {
116116
guard let length = length.flatMap(Int.init) else {
117117
return HTTPBodySequence(data: Data())
118118
}
@@ -124,7 +124,7 @@ struct HTTPDecoder {
124124
}
125125
}
126126

127-
static func makeBodyData<S: AsyncChunkedSequence>(from bytes: S, length: Int) async throws -> Data where S.Element == UInt8 {
127+
static func makeBodyData(from bytes: some AsyncChunkedSequence<UInt8>, length: Int) async throws -> Data {
128128
var iterator = bytes.makeAsyncIterator()
129129
guard let buffer = try await iterator.nextChunk(count: length) else {
130130
throw Error("AsyncChunkedSequence prematurely ended")

FlyingFox/Sources/WebSocket/AsyncStream+WSFrame.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import FlyingSocks
3333

3434
extension AsyncThrowingStream<WSFrame, any Error> {
3535

36-
static func decodingFrames<S: AsyncChunkedSequence>(from bytes: S) -> Self where S.Element == UInt8 {
36+
static func decodingFrames(from bytes: some AsyncChunkedSequence<UInt8>) -> Self {
3737
AsyncThrowingStream<WSFrame, any Error> {
3838
do {
3939
return try await WSFrameEncoder.decodeFrame(from: bytes)

FlyingFox/Sources/WebSocket/WSFrameEncoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct WSFrameEncoder {
6767
return data
6868
}
6969

70-
static func decodeFrame<S>(from bytes: S) async throws -> WSFrame where S: AsyncChunkedSequence, S.Element == UInt8 {
70+
static func decodeFrame(from bytes: some AsyncChunkedSequence<UInt8>) async throws -> WSFrame {
7171
var frame = try await decodeFrame(from: bytes.take())
7272
let (length, mask) = try await decodeLengthMask(from: bytes)
7373
frame.payload = try await decodePayload(from: bytes, length: length, mask: mask)

FlyingSocks/Sources/AsyncChunkedSequence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
//
3131

3232
/// AsyncSequence that is able to also receive elements in chunks, instead of just one-at-a-time.
33-
public protocol AsyncChunkedSequence: AsyncSequence where AsyncIterator: AsyncChunkedIteratorProtocol {
33+
public protocol AsyncChunkedSequence<Element>: AsyncSequence where AsyncIterator: AsyncChunkedIteratorProtocol {
3434

3535
}
3636

FlyingSocks/Sources/AsyncDataSequence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public struct AsyncDataSequence: AsyncSequence, Sendable {
3838

3939
private let loader: DataLoader
4040

41-
public init<S: AsyncChunkedSequence>(from bytes: S, count: Int, chunkSize: Int) where S.Element == UInt8 {
41+
public init(from bytes: some AsyncChunkedSequence<UInt8>, count: Int, chunkSize: Int) {
4242
self.loader = DataLoader(
4343
count: count,
4444
chunkSize: chunkSize,

0 commit comments

Comments
 (0)