AsyncSequence (ext)
You’re viewing third-party extensions to AsyncSequence
, a protocol from the Swift standard library.
You can also read the documentation forAsyncSequence
itself.
extension AsyncSequence
You’re viewing third-party extensions to AsyncSequence
, a protocol from the Swift standard library.
You can also read the documentation forAsyncSequence
itself.
extension AsyncSequence
protocol AsyncSequence<Element, Failure>
A type that provides asynchronous, sequential, iterated access to its elements.
import OpenAPIRuntime
Use and extend your client and server code generated by Swift OpenAPI Generator.
func asEncodedServerSentEvents() -> ServerSentEventsSerializationSequence<Self> where Self : Sendable, Self.Element == ServerSentEvent
Returns another sequence that encodes Server-sent Events with generic data in the data field.
func asEncodedServerSentEventsWithJSONData<JSONDataType>(encoder: JSONEncoder = {
let encoder = JSONEncoder()
encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]
return encoder
}()) -> ServerSentEventsSerializationSequence<AsyncThrowingMapSequence<Self, ServerSentEvent>> where Self : Sendable, JSONDataType : Encodable, JSONDataType : Hashable, JSONDataType : Sendable, Self.Element == ServerSentEventWithJSONData<JSONDataType>
Returns another sequence that encodes Server-sent Events that have a JSON value in the data field.
protocol Sendable
protocol Encodable
A type that can encode itself to an external representation.
func asEncodedJSONLines(encoder: JSONEncoder = {
let encoder = JSONEncoder()
encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]
return encoder
}()) -> JSONLinesSerializationSequence<AsyncThrowingMapSequence<Self, ArraySlice<UInt8>>>
Returns another sequence that encodes the events using the provided encoder into JSON Lines.
func asEncodedJSONSequence(encoder: JSONEncoder = {
let encoder = JSONEncoder()
encoder.outputFormatting = [.sortedKeys, .withoutEscapingSlashes]
return encoder
}()) -> JSONSequenceSerializationSequence<AsyncThrowingMapSequence<Self, ArraySlice<UInt8>>>
Returns another sequence that encodes the events using the provided encoder into a JSON Sequence.
@frozen struct ArraySlice<Element>
A slice of an Array
, ContiguousArray
, or ArraySlice
instance.
func asDecodedServerSentEvents(while predicate: @escaping (ArraySlice<UInt8>) -> Bool = { _ in true }) -> ServerSentEventsDeserializationSequence<ServerSentEventsLineDeserializationSequence<Self>>
Returns another sequence that decodes each event’s data as the provided type using the provided decoder.
func asDecodedServerSentEventsWithJSONData<JSONDataType>(of dataType: JSONDataType.Type = JSONDataType.self, decoder: JSONDecoder = .init(), while predicate: @escaping (ArraySlice<UInt8>) -> Bool = { _ in true }) -> AsyncThrowingMapSequence<ServerSentEventsDeserializationSequence<ServerSentEventsLineDeserializationSequence<Self>>, ServerSentEventWithJSONData<JSONDataType>> where JSONDataType : Decodable, JSONDataType : Hashable, JSONDataType : Sendable
Returns another sequence that decodes each event’s data as the provided type using the provided decoder.
func asDecodedServerSentEvents() -> ServerSentEventsDeserializationSequence<ServerSentEventsLineDeserializationSequence<Self>>
Returns another sequence that decodes each event’s data as the provided type using the provided decoder.
func asDecodedServerSentEventsWithJSONData<JSONDataType>(of dataType: JSONDataType.Type = JSONDataType.self, decoder: JSONDecoder = .init()) -> AsyncThrowingMapSequence<ServerSentEventsDeserializationSequence<ServerSentEventsLineDeserializationSequence<Self>>, ServerSentEventWithJSONData<JSONDataType>> where JSONDataType : Decodable, JSONDataType : Hashable, JSONDataType : Sendable
Returns another sequence that decodes each event’s data as the provided type using the provided decoder.
func asDecodedJSONLines<Event>(of eventType: Event.Type = Event.self, decoder: JSONDecoder = .init()) -> AsyncThrowingMapSequence<JSONLinesDeserializationSequence<Self>, Event> where Self : Sendable, Event : Decodable
Returns another sequence that decodes each JSON Lines event as the provided type using the provided decoder.
func asDecodedJSONSequence<Event>(of eventType: Event.Type = Event.self, decoder: JSONDecoder = .init()) -> AsyncThrowingMapSequence<JSONSequenceDeserializationSequence<Self>, Event> where Self : Sendable, Event : Decodable
Returns another sequence that decodes each JSON Sequence event as the provided type using the provided decoder.