Skip to content

Commit 59bf51e

Browse files
committed
EventStreams: remove non-closure overload incl. its tests
1 parent f1ff379 commit 59bf51e

File tree

2 files changed

+0
-92
lines changed

2 files changed

+0
-92
lines changed

Sources/OpenAPIRuntime/EventStreams/ServerSentEventsDecoding.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ extension AsyncSequence where Element == ArraySlice<UInt8>, Self: Sendable {
106106
ServerSentEventsLineDeserializationSequence<Self>
107107
> { .init(upstream: ServerSentEventsLineDeserializationSequence(upstream: self), terminate: terminate) }
108108

109-
/// Convenience function for `asDecodedServerSentEvents` that directly receives the terminating byte sequence.
110-
public func asDecodedServerSentEvents(terminatingSequence: ArraySlice<UInt8>) -> ServerSentEventsDeserializationSequence<
111-
ServerSentEventsLineDeserializationSequence<Self>
112-
> { asDecodedServerSentEvents(terminate: { incomingSequence in return incomingSequence == terminatingSequence }) }
113-
114109
/// Returns another sequence that decodes each event's data as the provided type using the provided decoder.
115110
///
116111
/// Use this method if the event's `data` field is JSON.
@@ -139,19 +134,6 @@ extension AsyncSequence where Element == ArraySlice<UInt8>, Self: Sendable {
139134
)
140135
}
141136
}
142-
143-
public func asDecodedServerSentEventsWithJSONData<JSONDataType: Decodable>(
144-
of dataType: JSONDataType.Type = JSONDataType.self,
145-
decoder: JSONDecoder = .init(),
146-
terminatingData: ArraySlice<UInt8>
147-
) -> AsyncThrowingMapSequence<
148-
ServerSentEventsDeserializationSequence<ServerSentEventsLineDeserializationSequence<Self>>,
149-
ServerSentEventWithJSONData<JSONDataType>
150-
> {
151-
asDecodedServerSentEventsWithJSONData(of: dataType, decoder: decoder) { incomingData in
152-
terminatingData == incomingData
153-
}
154-
}
155137
}
156138

157139
extension ServerSentEventsDeserializationSequence.Iterator {

Tests/OpenAPIRuntimeTests/EventStreams/Test_ServerSentEventsDecoding.swift

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,6 @@ final class Test_ServerSentEventsDecoding: Test_Runtime {
2929
}
3030
}
3131

32-
func _test(input: String, output: [ServerSentEvent], file: StaticString = #filePath, line: UInt = #line, terminatingData: ArraySlice<UInt8>, eventCountOffset: Int)
33-
async throws {
34-
try await _test(
35-
input: input,
36-
output: output,
37-
file: file,
38-
line: line,
39-
terminate: { incomingData in incomingData == terminatingData },
40-
eventCountOffset: eventCountOffset
41-
)
42-
}
43-
4432
func test() async throws {
4533
// Simple event.
4634
try await _test(
@@ -118,25 +106,6 @@ final class Test_ServerSentEventsDecoding: Test_Runtime {
118106
},
119107
eventCountOffset: -2
120108
)
121-
122-
try await _test(
123-
input: #"""
124-
data: hello
125-
data: world
126-
127-
data: [DONE]
128-
129-
data: hello2
130-
data: world2
131-
132-
133-
"""#,
134-
output: [
135-
.init(data: "hello\nworld")
136-
],
137-
terminatingData: ArraySlice<UInt8>(Data("[DONE]".utf8)),
138-
eventCountOffset: -2
139-
)
140109
}
141110
func _testJSONData<JSONType: Decodable & Hashable & Sendable>(
142111
input: String,
@@ -155,22 +124,6 @@ final class Test_ServerSentEventsDecoding: Test_Runtime {
155124
}
156125
}
157126

158-
func _testJSONData<JSONType: Decodable & Hashable & Sendable>(
159-
input: String,
160-
output: [ServerSentEventWithJSONData<JSONType>],
161-
file: StaticString = #filePath,
162-
line: UInt = #line,
163-
terminatingDataSequence: ArraySlice<UInt8>?
164-
) async throws {
165-
try await _testJSONData(
166-
input: input,
167-
output: output,
168-
file: file,
169-
terminate: { incomingData in incomingData == ArraySlice<UInt8>(Data("[DONE]".utf8))
170-
}
171-
)
172-
}
173-
174127
struct TestEvent: Decodable, Hashable, Sendable { var index: Int }
175128
func testJSONData() async throws {
176129
// Simple event.
@@ -222,33 +175,6 @@ final class Test_ServerSentEventsDecoding: Test_Runtime {
222175
incomingData == ArraySlice<UInt8>(Data("[DONE]".utf8))
223176
}
224177
)
225-
226-
try await _testJSONData(
227-
input: #"""
228-
event: event1
229-
id: 1
230-
data: {"index":1}
231-
232-
event: event2
233-
id: 2
234-
data: {
235-
data: "index": 2
236-
data: }
237-
238-
data: [DONE]
239-
240-
event: event3
241-
id: 1
242-
data: {"index":3}
243-
244-
245-
"""#,
246-
output: [
247-
.init(event: "event1", data: TestEvent(index: 1), id: "1"),
248-
.init(event: "event2", data: TestEvent(index: 2), id: "2"),
249-
],
250-
terminatingDataSequence: ArraySlice<UInt8>(Data("[DONE]".utf8))
251-
)
252178
}
253179
}
254180

0 commit comments

Comments
 (0)