Open weissi opened 2 days ago
What's the concrete ask here Johannes, a file.lines()
AsyncSequence
? Or a line reader on BufferedReader
?
What's the concrete ask here Johannes, a
file.lines()
AsyncSequence
? Or a line reader onBufferedReader
?
Both. a lines
and general composability of BufferedReader
so I can write things like lines
more easily.
I understand your ask here. IMO we should start with providing an AsyncSequence
way for now since this is the standard API for asynchronous streaming at this point.
I personally feel like a general protocol AsyncReader
and protocol AsyncWriter
is something very useful that we might want to introduce at the NIO level. Though I personally feel like they are standard library concepts.
Expected behavior
BufferedReader
is probably the best abstraction inNIOFileSystem
to stream a bunch of data. Real world examples include for example JSON lines (JSONL).I'd expect to be able to write
And for more complex schemes that aren't just newlines, I'd like to be able to write something composable on BufferedReader.
Actual behavior
Right now I use
But this is
while true
+guard !seenEOF
(_, _) =
UInt8("\n")
). If I wanted to support\r\n
&\n
, then this would get a lot more messySwiftNIO version/commit hash
2.77.0
FWIW, I also have another thing which allows me to use
but, it's very complex: