Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/AsyncSequenceReader/AsyncReadSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
// async-sequence-reader-watermark: 7E20A9CAB0604E89B17C6747A34F00C0
//

/// An AsyncSequence subtype suitable for reading an existing iterator in place.
/// An ``/AsyncSequenceReader/_Concurrency/AsyncSequence`` subtype suitable for reading an existing iterator in place.
///
/// Note that to conform to this protocol, your type must be a reference type. After iterating, you'll also likely want to copy the base iterator back into your starting iterator, as shown in ``AsyncIteratorProtocol/transform(with:readSequenceFactory:)``.
/// Note that to conform to this protocol, your type must be a reference type. After iterating, you'll also likely want to copy the base iterator back into your starting iterator, as shown in ``/AsyncSequenceReader/_Concurrency/AsyncIteratorProtocol/transform(with:readSequenceFactory:)``.
public protocol AsyncReadSequence: AsyncSequence, AnyObject {
associatedtype BaseIterator: AsyncIteratorProtocol where BaseIterator.Element == Element

Expand Down
16 changes: 8 additions & 8 deletions Sources/AsyncSequenceReader/AsyncReadUpToElementsSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extension AsyncIteratorProtocol where Element: Equatable {
/// ```
///
/// - Parameter termination: The element marking the end of the sequence that will be collected.
/// - Parameter throwsIfOver: The maximum amount of elements that will be read before an error is thrown if a termination is not detected.
/// - Parameter maximumBufferSize: The maximum amount of elements that will be read before an error is thrown if a termination is not detected.
/// - Returns: An array of the collected elements, or `nil` if the sequence was already finished.
/// - Throws: ``AsyncSequenceReaderError/terminationNotFound(maximum:actual:)`` if a complete byte sequence could not be returned by the time the sequence ended.
@inlinable
Expand Down Expand Up @@ -65,7 +65,7 @@ extension AsyncIteratorProtocol where Element: Equatable {
/// ```
///
/// - Parameter termination: The sequence of elements marking the end of the sequence that will be collected.
/// - Parameter throwsIfOver: The maximum amount of elements that will be read before an error is thrown if a termination is not detected.
/// - Parameter maximumBufferSize: The maximum amount of elements that will be read before an error is thrown if a termination is not detected.
/// - Returns: An array of the collected elements, or `nil` if the sequence was already finished.
/// - Throws: ``AsyncSequenceReaderError/terminationNotFound(maximum:actual:)`` if a complete byte sequence could not be returned by the time the sequence ended.
@inlinable
Expand Down Expand Up @@ -116,7 +116,7 @@ extension AsyncIteratorProtocol where Element: Equatable {
/// ```
///
/// - Parameter termination: The element marking the end of the sequence that will be collected.
/// - Parameter throwsIfOver: The maximum amount of elements that will be read before an error is thrown if a termination is not detected.
/// - Parameter maximumBufferSize: The maximum amount of elements that will be read before an error is thrown if a termination is not detected.
/// - Returns: An array of the collected elements, or `nil` if the sequence was already finished.
/// - Throws: ``AsyncSequenceReaderError/terminationNotFound(maximum:actual:)`` if a complete byte sequence could not be returned by the time the sequence ended.
@inlinable
Expand Down Expand Up @@ -150,7 +150,7 @@ extension AsyncIteratorProtocol where Element: Equatable {
/// ```
///
/// - Parameter termination: The sequence of elements marking the end of the sequence that will be collected.
/// - Parameter throwsIfOver: The maximum amount of elements that will be read before an error is thrown if a termination is not detected.
/// - Parameter maximumBufferSize: The maximum amount of elements that will be read before an error is thrown if a termination is not detected.
/// - Returns: An array of the collected elements, or `nil` if the sequence was already finished.
/// - Throws: ``AsyncSequenceReaderError/terminationNotFound(maximum:actual:)`` if a complete byte sequence could not be returned by the time the sequence ended.
@inlinable
Expand Down Expand Up @@ -187,7 +187,7 @@ extension AsyncIteratorProtocol where Element: Equatable, Failure == Never {
/// ```
///
/// - Parameter termination: The element marking the end of the sequence that will be collected.
/// - Parameter throwsIfOver: The maximum amount of elements that will be read before an error is thrown if a termination is not detected.
/// - Parameter maximumBufferSize: The maximum amount of elements that will be read before an error is thrown if a termination is not detected.
/// - Returns: An array of the collected elements, or `nil` if the sequence was already finished.
/// - Throws: ``AsyncSequenceReaderError/terminationNotFound(maximum:actual:)`` if a complete byte sequence could not be returned by the time the sequence ended.
@inlinable
Expand Down Expand Up @@ -242,7 +242,7 @@ extension AsyncIteratorProtocol where Element: Equatable, Failure == Never {
/// ```
///
/// - Parameter termination: The sequence of elements marking the end of the sequence that will be collected.
/// - Parameter throwsIfOver: The maximum amount of elements that will be read before an error is thrown if a termination is not detected.
/// - Parameter maximumBufferSize: The maximum amount of elements that will be read before an error is thrown if a termination is not detected.
/// - Returns: An array of the collected elements, or `nil` if the sequence was already finished.
/// - Throws: ``AsyncSequenceReaderError/terminationNotFound(maximum:actual:)`` if a complete byte sequence could not be returned by the time the sequence ended.
@inlinable
Expand Down Expand Up @@ -293,7 +293,7 @@ extension AsyncIteratorProtocol where Element: Equatable, Failure == Never {
/// ```
///
/// - Parameter termination: The element marking the end of the sequence that will be collected.
/// - Parameter throwsIfOver: The maximum amount of elements that will be read before an error is thrown if a termination is not detected.
/// - Parameter maximumBufferSize: The maximum amount of elements that will be read before an error is thrown if a termination is not detected.
/// - Returns: An array of the collected elements, or `nil` if the sequence was already finished.
/// - Throws: ``AsyncSequenceReaderError/terminationNotFound(maximum:actual:)`` if a complete byte sequence could not be returned by the time the sequence ended.
@inlinable
Expand Down Expand Up @@ -348,7 +348,7 @@ extension AsyncIteratorProtocol where Element: Equatable, Failure == Never {
/// ```
///
/// - Parameter termination: The sequence of elements marking the end of the sequence that will be collected.
/// - Parameter throwsIfOver: The maximum amount of elements that will be read before an error is thrown if a termination is not detected.
/// - Parameter maximumBufferSize: The maximum amount of elements that will be read before an error is thrown if a termination is not detected.
/// - Returns: An array of the collected elements, or `nil` if the sequence was already finished.
/// - Throws: ``AsyncSequenceReaderError/terminationNotFound(maximum:actual:)`` if a complete byte sequence could not be returned by the time the sequence ended.
@inlinable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# ``AsyncSequenceReader``

``AsyncSequenceReader`` provides building blocks to easily consume Swift's ``/Swift/AsyncSequence``.
``AsyncSequenceReader`` provides building blocks to easily consume Swift's ``/AsyncSequenceReader/_Concurrency/AsyncSequence``.

## What is ``AsyncSequenceReader``?

``AsyncSequenceReader`` is a collection of building blocks to make it easy to read information and transform `AsyncSequence` into data types your app understands.

Although an ``/Swift/AsyncSequence`` can be consumed via a `for await` loop, that isn't often the easiest way of consuming that data:
Although an ``/AsyncSequenceReader/_Concurrency/AsyncSequence`` can be consumed via a `for await` loop, that isn't often the easiest way of consuming that data:

```swift

Expand Down Expand Up @@ -56,7 +56,7 @@ Reading values is as easy as calling `let value = try await iterator.next()`. Th

Note: Resist the urge to catch errors within an iterator map, as once a value is read, it will no longer be available.

Returning an object will make it available to whoever is consuming the resulting sequence, preparing your closure to be called again for the next object. Do note that Your closure will not be called unless something consumes your `results` sequence, either via `for await`, or by using `.reduce` or other ``/Swift/AsyncSequence`` methods.
Returning an object will make it available to whoever is consuming the resulting sequence, preparing your closure to be called again for the next object. Do note that Your closure will not be called unless something consumes your `results` sequence, either via `for await`, or by using `.reduce` or other ``/AsyncSequenceReader/_Concurrency/AsyncSequence`` methods.

Note: Do not copy the iterator to other methods without marking it as `inout`, since as a value type, a copy will be made, and further reads may become out of sync.

Expand Down