read(while:)
Reads from the current position in the file until predicate
returns false
and returns the read bytes.
- iOS
- 13.0+
- macOS
- 10.15+
- tvOS
- 13.0+
- watchOS
- 6.0+
mutating func read(while predicate: (UInt8) -> Bool) async throws -> (bytes: ByteBuffer, readEOF: Bool)
Parameters
- predicate
A predicate which evaluates to
true
for all bytes returned.
Returns
A tuple containing the bytes read from the file in its first component, and a boolean indicating whether we’ve stopped reading because EOF has been reached, or because the predicate condition doesn’t hold true anymore.