in Sources/TSFCAS/Implementations/FileBackedCASDatabase.swift [66:84]
func readFile(file: AbsolutePath) -> LLBFuture<ByteBuffer> {
let handleAndRegion = fileIO.openFile(
path: file.pathString, eventLoop: group.next()
)
let data: LLBFuture<LLBByteBuffer> = handleAndRegion.flatMap { (handle, region) in
let allocator = ByteBufferAllocator()
return self.fileIO.read(
fileRegion: region,
allocator: allocator,
eventLoop: self.group.next()
)
}
return handleAndRegion.and(data).flatMapThrowing { (handle, data) in
try handle.0.close()
return data
}
}