pub fn sendFile(w: *Writer, file_reader: *File.Reader, limit: Limit) FileError!usize ReadFailedDetailed diagnostics are found on the File.Reader struct.
WriteFailedSee the Writer implementation for detailed diagnostics.
EndOfStreamReached the end of the file being read.
UnimplementedIndicates the caller should do its own file reading; the callee cannot offer a more efficient implementation.
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396 pub fn sendFile(w: *Writer, file_reader: *File.Reader, limit: Limit) FileError!usize {
if (File.Handle == void) return error.Unimplemented;
const d: *Discarding = @alignCast(@fieldParentPtr("writer", w));
d.count += w.end;
w.end = 0;
if (limit == .nothing) return 0;
if (file_reader.getSize()) |size| {
const n = limit.minInt64(size - file_reader.pos);
if (n == 0) return error.EndOfStream;
file_reader.seekBy(@intCast(n)) catch return error.Unimplemented;
w.end = 0;
d.count += n;
return n;
} else |_| {
// Error is observable on `file_reader` instance, and it is better to
// treat the file as a pipe.
return error.Unimplemented;
}
}