Wrong api docs
makhocheung opened this issue · 2 comments
makhocheung commented
makhocheung commented
Code from FileIO+Concurrency.swift
/// Reads the contents of a file at the supplied path in chunks.
///
/// try await req.fileio().readChunked(file: "/path/to/file.txt") { chunk in
/// print("chunk: \(data)")
/// }
///
/// - parameters:
/// - path: Path to file on the disk.
/// - chunkSize: Maximum size for the file data chunks.
/// - onRead: Closure to be called sequentially for each file data chunk.
/// - returns: `Void` when the file read is finished.
// public func readFile(at path: String, chunkSize: Int = NonBlockingFileIO.defaultChunkSize, onRead: @escaping (ByteBuffer) async throws -> Void) async throws {
// // TODO
// // We should probably convert the internal private read function to async as well rather than wrapping it at this top level
// let promise = self.request.eventLoop.makePromise(of: Void.self)
// promise.completeWithTask {
// try await onRead
// }
// let closureFuture = promise.futureResult
// return try self.readFile(at: path, onRead: closureFuture).get()
// }
I'm confused why this code is commented out
0xTim commented
@makhocheung it's commented out because there was an issue with the concurrency/NIO integration for making it work. Feel free to try adding it though!