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.
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881 fn sendFile(w: *Writer, file_reader: *File.Reader, limit: Limit) FileError!usize {
if (File.Handle == void) return error.Unimplemented;
if (limit == .nothing) return 0;
const a: *Allocating = @fieldParentPtr("writer", w);
const pos = file_reader.logicalPos();
const additional, const exact = if (file_reader.getSize()) |size|
.{ size - pos, true }
else |_|
.{ std.atomic.cache_line, false };
if (additional == 0) return error.EndOfStream;
a.ensureUnusedCapacity(limit.minInt64(additional)) catch return error.WriteFailed;
const buffer = a.writer.buffer[a.writer.end..];
const dest = if (exact) buffer[0..limit.minInt64(additional)] else limit.slice(buffer);
const n = try file_reader.interface.readSliceShort(dest);
if (n == 0) return error.EndOfStream;
a.writer.end += n;
return n;
}