mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
Implement asyncfile.readToStream.
This commit is contained in:
@@ -489,3 +489,13 @@ proc writeFromStream*(f: AsyncFile, fs: FutureStream[string]) {.async.} =
|
||||
await f.write(value)
|
||||
else:
|
||||
break
|
||||
|
||||
proc readToStream*(f: AsyncFile, fs: FutureStream[string]) {.async.} =
|
||||
## Writes data to the specified future stream as the file is read.
|
||||
while true:
|
||||
let data = await read(f, 4000)
|
||||
if data.len == 0:
|
||||
break
|
||||
await fs.write(data)
|
||||
|
||||
fs.complete()
|
||||
Reference in New Issue
Block a user