Skip to content

Commit fcef21b

Browse files
Updated Bytes-related documentation
1 parent 47c27c1 commit fcef21b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ for await dataFrame in results {
175175
}
176176
```
177177

178-
Better yet, [Bytes](https://github.com/mochidev/Bytes) will soon be getting support for reading from `AsyncIteratorProtocol` directly, allowing you to simplify the above to:
178+
Better yet, [Bytes](https://github.com/mochidev/Bytes) also has support for reading from `AsyncIteratorProtocol` directly, allowing you to simplify the above to:
179179

180180
```swift
181181
struct DataFrame {
@@ -189,10 +189,10 @@ let sequence = url.resourceBytes
189189
let results = sequence.iteratorMap { iterator -> DataFrame? in
190190
var payloadSize = try await iterator.next(bigEndian: UInt32.self)
191191

192-
let commandString = try await iterator.next(utf8StringUpToExcluding: 0, throwsIfOver: min(256, payloadSize))
192+
let commandString = try await iterator.next(utf8: String.self, upToExcluding: 0, throwsIfOver: min(256, payloadSize))
193193
payloadSize -= commandString.utf8.count - 1 // Don't forget the null byte we skipped
194194

195-
guard let payloadBytes = try await iterator.count(payloadSize) else { throw DataFrameError.missingPayload }
195+
let payloadBytes = try await iterator.next(bytes: Bytes.self, count: payloadSize)
196196

197197
return DataFrame(command: commandString, payload: payloadBytes)
198198
}

0 commit comments

Comments
 (0)