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 › Io › Dispatch › fileReadStreamingLimit Private Function fileReadStreamingLimit Doc Source Private Function std.Io.Dispatch.fileReadStreamingLimit
fn fileReadStreamingLimit (
handle : File .Handle ,
data : []const []u8 ,
limit : Io .Limit ,
) File .ReadStreamingError !usize Params handle : File .Handle data : []const []u8 limit : Io .Limit File Io/Dispatch.zig: 1750
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780 fn fileReadStreamingLimit (
handle : File .Handle ,
data : []const []u8 ,
limit : Io .Limit ,
) File .ReadStreamingError !usize {
var iovecs : [max_iovecs_len ]iovec = undefined ;
var iovlen : iovlen_t = 0 ;
// .nothing can mean that the write side has been closed,
// in which case the buffer still needs to be drained
var remaining = if (limit == .nothing ) .unlimited else limit ;
for (data ) |buf | addBuf (false , &iovecs , &iovlen , &remaining , buf );
if (iovlen == 0 ) return 0 ;
while (true ) {
const rc = c .readv (handle , &iovecs , iovlen );
switch (c .errno (rc )) {
.SUCCESS => return if (rc == 0 ) error .EndOfStream else @intCast (rc ),
.INTR => continue ,
.INVAL => |err | return errnoBug (err ),
.FAULT => |err | return errnoBug (err ),
.AGAIN => return error .WouldBlock ,
.BADF => |err | return errnoBug (err ), // File descriptor used after closed
.IO => return error .InputOutput ,
.ISDIR => return error .IsDir ,
.NOBUFS => return error .SystemResources ,
.NOMEM => return error .SystemResources ,
.NOTCONN => return error .SocketUnconnected ,
.CONNRESET => return error .ConnectionResetByPeer ,
else => |err | return unexpectedErrno (err ),
}
}
}