extension AsyncIteratorProtocol where Element == UInt8 {
public mutating func collect(
utf8: String.Type,
upToExcluding termination: StringProtocol,
throwsIfOver maximumBufferSize: Int
) async throws -> String? {
let bytes = try await iterator.collect(upToExcluding: termination.utf8, throwsIfOver: throwsIfOver))
return bytes.map { String(decoding: $0, as: UTF8.self) }
}
}