WebSocketInboundStream
Inbound WebSocket data frame AsyncSequence
final class WebSocketInboundStream
This AsyncSequence only returns binary, text and continuation frames. All other frames are dealt with internally
Inbound WebSocket data frame AsyncSequence
final class WebSocketInboundStream
This AsyncSequence only returns binary, text and continuation frames. All other frames are dealt with internally
import WSCore
protocol AsyncSequence<Element, Failure>
A type that provides asynchronous, sequential, iterated access to its elements.
protocol Sendable
func makeAsyncIterator() -> AsyncIterator
Creates the Asynchronous Iterator
func messages(maxSize: Int) -> WebSocketInboundMessageStream
Convert to AsyncSequence of WebSocket messages
struct AsyncIterator
Inbound websocket data AsyncSequence iterator
typealias Element = WebSocketDataFrame
func _throttle<C>(for interval: C.Instant.Duration, clock: C, latest: Bool = true) -> _AsyncThrottleSequence<Self, C, Element> where C : Clock
Create a rate-limited AsyncSequence
by emitting values at most every specified interval.
func _throttle<C, Reduced>(for interval: C.Instant.Duration, clock: C, reducing: @escaping (Reduced?, Element) async -> Reduced) -> _AsyncThrottleSequence<Self, C, Reduced> where C : Clock
Create a rate-limited AsyncSequence
by emitting values at most every specified interval.
func _throttle(for interval: Duration, latest: Bool = true) -> _AsyncThrottleSequence<Self, ContinuousClock, Element>
Create a rate-limited AsyncSequence
by emitting values at most every specified interval.
func _throttle<Reduced>(for interval: Duration, reducing: @escaping (Reduced?, Element) async -> Reduced) -> _AsyncThrottleSequence<Self, ContinuousClock, Reduced>
Create a rate-limited AsyncSequence
by emitting values at most every specified interval.
func adjacentPairs() -> AsyncAdjacentPairsSequence<Self>
An AsyncSequence
that iterates over the adjacent pairs of the original original AsyncSequence
.
func allSatisfy(_ predicate: (Self.Element) async throws -> Bool) async rethrows -> Bool
Returns a Boolean value that indicates whether all elements produced by the asynchronous sequence satisfy the given predicate.
func buffer(policy: AsyncBufferSequencePolicy) -> AsyncBufferSequence<Self>
Creates an asynchronous sequence that buffers elements.
func cancelOnGracefulShutdown() -> AsyncCancelOnGracefulShutdownSequence<Self>
Creates an asynchronous sequence that is cancelled once graceful shutdown has triggered.
func chunked(by belongInSameGroup: @escaping (Element, Element) -> Bool) -> AsyncChunkedByGroupSequence<Self, [Element]>
Creates an asynchronous sequence that creates chunks by testing if elements belong in the same group.
func chunked<C, Collected>(by timer: AsyncTimerSequence<C>, into: Collected.Type) -> AsyncChunksOfCountOrSignalSequence<Self, Collected, AsyncTimerSequence<C>> where Self : Sendable, C : Clock, Collected : RangeReplaceableCollection, Self.Element : Sendable, Self.Element == Collected.Element
Creates an asynchronous sequence that creates chunks of a given RangeReplaceableCollection
type when an AsyncTimerSequence
fires.
func chunked<Signal, Collected>(by signal: Signal, into: Collected.Type) -> AsyncChunksOfCountOrSignalSequence<Self, Collected, Signal> where Self : Sendable, Signal : Sendable, Signal : AsyncSequence, Collected : RangeReplaceableCollection, Self.Element : Sendable, Self.Element == Collected.Element, Signal.Element : Sendable
Creates an asynchronous sequence that creates chunks of a given RangeReplaceableCollection
type when a signal AsyncSequence
produces an element.
func chunked<Collected>(into: Collected.Type, by belongInSameGroup: @escaping (Element, Element) -> Bool) -> AsyncChunkedByGroupSequence<Self, Collected> where Collected : RangeReplaceableCollection, Self.Element == Collected.Element
Creates an asynchronous sequence that creates chunks of a given RangeReplaceableCollection
type by testing if elements belong in the same group.
func chunked<Subject, Collected>(into: Collected.Type, on projection: @escaping (Element) -> Subject) -> AsyncChunkedOnProjectionSequence<Self, Subject, Collected> where Subject : Equatable, Collected : RangeReplaceableCollection, Self.Element == Collected.Element
Creates an asynchronous sequence that creates chunks of a given RangeReplaceableCollection
type on the uniqueness of a given subject.
func chunked<Subject>(on projection: @escaping (Element) -> Subject) -> AsyncChunkedOnProjectionSequence<Self, Subject, [Element]> where Subject : Equatable
Creates an asynchronous sequence that creates chunks on the uniqueness of a given subject.
func chunks(ofCount count: Int) -> AsyncChunksOfCountSequence<Self, [Element]>
Creates an asynchronous sequence that creates chunks of a given count.
func chunks<Collected>(ofCount count: Int, into: Collected.Type) -> AsyncChunksOfCountSequence<Self, Collected> where Collected : RangeReplaceableCollection, Self.Element == Collected.Element
Creates an asynchronous sequence that creates chunks of a given RangeReplaceableCollection
of a given count.
func chunks<C>(ofCount count: Int, or timer: AsyncTimerSequence<C>) -> AsyncChunksOfCountOrSignalSequence<Self, [Element], AsyncTimerSequence<C>> where Self : Sendable, C : Clock, Self.Element : Sendable
Creates an asynchronous sequence that creates chunks of a given count or when an AsyncTimerSequence
fires.
func chunks<Signal>(ofCount count: Int, or signal: Signal) -> AsyncChunksOfCountOrSignalSequence<Self, [Element], Signal> where Self : Sendable, Signal : Sendable, Signal : AsyncSequence, Self.Element : Sendable, Signal.Element : Sendable
Creates an asynchronous sequence that creates chunks of a given count or when a signal AsyncSequence
produces an element.
func chunks<C, Collected>(ofCount count: Int, or timer: AsyncTimerSequence<C>, into: Collected.Type) -> AsyncChunksOfCountOrSignalSequence<Self, Collected, AsyncTimerSequence<C>> where Self : Sendable, C : Clock, Collected : RangeReplaceableCollection, Self.Element : Sendable, Self.Element == Collected.Element
Creates an asynchronous sequence that creates chunks of a given RangeReplaceableCollection
type of a given count or when an AsyncTimerSequence
fires.
func chunks<Signal, Collected>(ofCount count: Int, or signal: Signal, into: Collected.Type) -> AsyncChunksOfCountOrSignalSequence<Self, Collected, Signal> where Self : Sendable, Signal : Sendable, Signal : AsyncSequence, Collected : RangeReplaceableCollection, Self.Element : Sendable, Self.Element == Collected.Element, Signal.Element : Sendable
Creates an asynchronous sequence that creates chunks of a given RangeReplaceableCollection
type of a given count or when a signal AsyncSequence
produces an element.
@preconcurrency func compactMap<ElementOfResult>(_ transform: @escaping (Self.Element) async -> ElementOfResult?) -> AsyncCompactMapSequence<Self, ElementOfResult>
Creates an asynchronous sequence that maps the given closure over the asynchronous sequence’s elements, omitting results that don’t return a value.
@preconcurrency func compactMap<ElementOfResult>(_ transform: @escaping (Self.Element) async throws -> ElementOfResult?) -> AsyncThrowingCompactMapSequence<Self, ElementOfResult>
Creates an asynchronous sequence that maps an error-throwing closure over the base sequence’s elements, omitting results that don’t return a value.
func compacted<Unwrapped>() -> AsyncCompactedSequence<Self, Unwrapped> where Self.Element == Unwrapped?
Returns a new AsyncSequence
that iterates over every non-nil element from the original AsyncSequence
.
func contains(_ search: Self.Element) async rethrows -> Bool
Returns a Boolean value that indicates whether the asynchronous sequence contains the given element.
func contains(where predicate: (Self.Element) async throws -> Bool) async rethrows -> Bool
Returns a Boolean value that indicates whether the asynchronous sequence contains an element that satisfies the given predicate.
func debounce(for interval: Duration, tolerance: Duration? = nil) -> AsyncDebounceSequence<Self, ContinuousClock> where Self : Sendable, Self.Element : Sendable
Creates an asynchronous sequence that emits the latest element after a given quiescence period has elapsed.
func debounce<C>(for interval: C.Instant.Duration, tolerance: C.Instant.Duration? = nil, clock: C) -> AsyncDebounceSequence<Self, C> where Self : Sendable, C : Clock, Self.Element : Sendable
Creates an asynchronous sequence that emits the latest element after a given quiescence period has elapsed by using a specified Clock.
@preconcurrency func drop(while predicate: @escaping (Self.Element) async -> Bool) -> AsyncDropWhileSequence<Self>
Omits elements from the base asynchronous sequence until a given closure returns false, after which it passes through all remaining elements.
func dropFirst(_ count: Int = 1) -> AsyncDropFirstSequence<Self>
Omits a specified number of elements from the base asynchronous sequence, then passes through all remaining elements.
@preconcurrency func filter(_ isIncluded: @escaping (Self.Element) async -> Bool) -> AsyncFilterSequence<Self>
Creates an asynchronous sequence that contains, in order, the elements of the base sequence that satisfy the given predicate.
func first(where predicate: (Self.Element) async throws -> Bool) async rethrows -> Self.Element?
Returns the first element of the sequence that satisfies the given predicate.
@preconcurrency func flatMap<SegmentOfResult>(_ transform: @escaping (Self.Element) async throws -> SegmentOfResult) -> AsyncThrowingFlatMapSequence<Self, SegmentOfResult> where SegmentOfResult : AsyncSequence
Creates an asynchronous sequence that concatenates the results of calling the given error-throwing transformation with each element of this sequence.
@preconcurrency func flatMap<SegmentOfResult>(_ transform: @escaping (Self.Element) async -> SegmentOfResult) -> AsyncFlatMapSequence<Self, SegmentOfResult> where SegmentOfResult : AsyncSequence, Self.Failure == SegmentOfResult.Failure
Creates an asynchronous sequence that concatenates the results of calling the given transformation with each element of this sequence.
@preconcurrency func flatMap<SegmentOfResult>(_ transform: @escaping (Self.Element) async -> SegmentOfResult) -> AsyncFlatMapSequence<Self, SegmentOfResult> where SegmentOfResult : AsyncSequence, SegmentOfResult.Failure == Never
Creates an asynchronous sequence that concatenates the results of calling the given transformation with each element of this sequence.
@preconcurrency func flatMap<SegmentOfResult>(_ transform: @escaping (Self.Element) async -> SegmentOfResult) -> AsyncFlatMapSequence<Self, SegmentOfResult> where SegmentOfResult : AsyncSequence, Self.Failure == Never, SegmentOfResult.Failure == Never
Creates an asynchronous sequence that concatenates the results of calling the given transformation with each element of this sequence.
func interspersed(every: Int = 1, with separator: Element) -> AsyncInterspersedSequence<Self>
Returns a new asynchronous sequence containing the elements of this asynchronous sequence, inserting the given separator between each element.
func interspersed(every: Int = 1, with separator: @escaping () async -> Element) -> AsyncInterspersedSequence<Self>
Returns a new asynchronous sequence containing the elements of this asynchronous sequence, inserting the given separator between each element.
func interspersed(every: Int = 1, with separator: @escaping () -> Element) -> AsyncInterspersedSequence<Self>
Returns a new asynchronous sequence containing the elements of this asynchronous sequence, inserting the given separator between each element.
func interspersed(every: Int = 1, with separator: @escaping () async throws -> Element) -> AsyncThrowingInterspersedSequence<Self>
Returns a new asynchronous sequence containing the elements of this asynchronous sequence, inserting the given separator between each element.
func interspersed(every: Int = 1, with separator: @escaping () throws -> Element) -> AsyncThrowingInterspersedSequence<Self>
Returns a new asynchronous sequence containing the elements of this asynchronous sequence, inserting the given separator between each element.
@preconcurrency func map<Transformed>(_ transform: @escaping (Self.Element) async -> Transformed) -> AsyncMapSequence<Self, Transformed>
Creates an asynchronous sequence that maps the given closure over the asynchronous sequence’s elements.
@preconcurrency func map<Transformed>(_ transform: @escaping (Self.Element) async throws -> Transformed) -> AsyncThrowingMapSequence<Self, Transformed>
Creates an asynchronous sequence that maps the given error-throwing closure over the asynchronous sequence’s elements.
@warn_unqualified_access func max(by areInIncreasingOrder: (Self.Element, Self.Element) async throws -> Bool) async rethrows -> Self.Element?
Returns the maximum element in the asynchronous sequence, using the given predicate as the comparison between elements.
@warn_unqualified_access func min(by areInIncreasingOrder: (Self.Element, Self.Element) async throws -> Bool) async rethrows -> Self.Element?
Returns the minimum element in the asynchronous sequence, using the given predicate as the comparison between elements.
func prefix(_ count: Int) -> AsyncPrefixSequence<Self>
Returns an asynchronous sequence, up to the specified maximum length, containing the initial elements of the base asynchronous sequence.
@preconcurrency func prefix(while predicate: @escaping (Self.Element) async -> Bool) rethrows -> AsyncPrefixWhileSequence<Self>
Returns an asynchronous sequence, containing the initial, consecutive elements of the base sequence that satisfy the given predicate.
func reduce<Result>(_ initialResult: Result, _ nextPartialResult: (Result, Self.Element) async throws -> Result) async rethrows -> Result
Returns the result of combining the elements of the asynchronous sequence using the given closure.
func reduce<Result>(into initialResult: Result, _ updateAccumulatingResult: (inout Result, Self.Element) async throws -> Void) async rethrows -> Result
Returns the result of combining the elements of the asynchronous sequence using the given closure, given a mutable initial value.
func reductions(_ transform: @escaping (Element, Element) async -> Element) -> AsyncInclusiveReductionsSequence<Self>
Returns an asynchronous sequence containing the accumulated results of combining the elements of the asynchronous sequence using the given closure.
func reductions<Result>(_ initial: Result, _ transform: @escaping (Result, Element) async -> Result) -> AsyncExclusiveReductionsSequence<Self, Result>
Returns an asynchronous sequence containing the accumulated results of combining the elements of the asynchronous sequence using the given closure.
func reductions<Result>(_ initial: Result, _ transform: @escaping (Result, Element) async throws -> Result) -> AsyncThrowingExclusiveReductionsSequence<Self, Result>
Returns an asynchronous sequence containing the accumulated results of combining the elements of the asynchronous sequence using the given error-throwing closure.
func reductions<Result>(into initial: Result, _ transform: @escaping (inout Result, Element) async -> Void) -> AsyncExclusiveReductionsSequence<Self, Result>
Returns an asynchronous sequence containing the accumulated results of combining the elements of the asynchronous sequence using the given closure.
func reductions<Result>(into initial: Result, _ transform: @escaping (inout Result, Element) async throws -> Void) -> AsyncThrowingExclusiveReductionsSequence<Self, Result>
Returns an asynchronous sequence containing the accumulated results of combining the elements of the asynchronous sequence using the given error-throwing closure.
func removeDuplicates() -> AsyncRemoveDuplicatesSequence<Self>
Creates an asynchronous sequence that omits repeated elements.
func removeDuplicates(by predicate: @escaping (Element, Element) async -> Bool) -> AsyncRemoveDuplicatesSequence<Self>
Creates an asynchronous sequence that omits repeated elements by testing them with a predicate.