| ... | @@ -882,6 +882,9 @@ pub fn writeSliceSwap(w: *Writer, Elem: type, slice: []const Elem) Error!void { | ... | @@ -882,6 +882,9 @@ pub fn writeSliceSwap(w: *Writer, Elem: type, slice: []const Elem) Error!void { |
| 882 | /// Unlike `writeSplat` and `writeVec`, this function will call into `VTable` | 882 | /// Unlike `writeSplat` and `writeVec`, this function will call into `VTable` |
| 883 | /// even if there is enough buffer capacity for the file contents. | 883 | /// even if there is enough buffer capacity for the file contents. |
| 884 | /// | 884 | /// |
| | 885 | /// The caller is responsible for flushing. Although the buffer may be bypassed |
| | 886 | /// as an optimization, this is not a guarantee. |
| | 887 | /// |
| 885 | /// Although it would be possible to eliminate `error.Unimplemented` from the | 888 | /// Although it would be possible to eliminate `error.Unimplemented` from the |
| 886 | /// error set by reading directly into the buffer in such case, this is not | 889 | /// error set by reading directly into the buffer in such case, this is not |
| 887 | /// done because it is more efficient to do it higher up the call stack so that | 890 | /// done because it is more efficient to do it higher up the call stack so that |
| ... | @@ -924,7 +927,16 @@ pub fn sendFileReading(w: *Writer, file_reader: *File.Reader, limit: Limit) File | ... | @@ -924,7 +927,16 @@ pub fn sendFileReading(w: *Writer, file_reader: *File.Reader, limit: Limit) File |
| 924 | | 927 | |
| 925 | /// Number of bytes logically written is returned. This excludes bytes from | 928 | /// Number of bytes logically written is returned. This excludes bytes from |
| 926 | /// `buffer` because they have already been logically written. | 929 | /// `buffer` because they have already been logically written. |
| | 930 | /// |
| | 931 | /// The caller is responsible for flushing. Although the buffer may be bypassed |
| | 932 | /// as an optimization, this is not a guarantee. |
| | 933 | /// |
| | 934 | /// Asserts nonzero buffer capacity. |
| 927 | pub fn sendFileAll(w: *Writer, file_reader: *File.Reader, limit: Limit) FileAllError!usize { | 935 | pub fn sendFileAll(w: *Writer, file_reader: *File.Reader, limit: Limit) FileAllError!usize { |
| | 936 | // The fallback sendFileReadingAll() path asserts non-zero buffer capacity. |
| | 937 | // Explicitly assert it here as well to ensure the assert is hit even if |
| | 938 | // the fallback path is not taken. |
| | 939 | assert(w.buffer.len > 0); |
| 928 | var remaining = @intFromEnum(limit); | 940 | var remaining = @intFromEnum(limit); |
| 929 | while (remaining > 0) { | 941 | while (remaining > 0) { |
| 930 | const n = sendFile(w, file_reader, .limited(remaining)) catch |err| switch (err) { | 942 | const n = sendFile(w, file_reader, .limited(remaining)) catch |err| switch (err) { |