Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › http › BodyWriter › elidingSendFile Public Function elidingSendFile Doc Source Public Function std.http.BodyWriter.elidingSendFile
pub fn elidingSendFile (w : *Writer , file_reader : *File .Reader , limit : std .Io .Limit ) Writer .FileError !usize Params File http.zig: 917
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941 pub fn elidingSendFile (w : *Writer , file_reader : *File .Reader , limit : std .Io .Limit ) Writer .FileError !usize {
const bw : *BodyWriter = @alignCast (@fieldParentPtr ("writer" , w ));
if (File .Handle == void ) return error .Unimplemented ;
if (builtin .zig_backend == .stage2_aarch64 ) return error .Unimplemented ;
switch (bw .state ) {
.content_length => |*len | len .* -= w .end ,
else => {},
}
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 ;
switch (bw .state ) {
.content_length => |*len | len .* -= n ,
else => {},
}
return n ;
} else |_ | {
// Error is observable on `file_reader` instance, and it is better to
// treat the file as a pipe.
return error .Unimplemented ;
}
}