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 › fileReadPositional Private Function fileReadPositional Doc Source Private Function std.Io.Dispatch.fileReadPositional
fn fileReadPositional (
userdata : ?*anyopaque ,
file : File ,
data : []const []u8 ,
offset : u64 ,
) File .ReadPositionalError !usize Params userdata : ?*anyopaque file : File data : []const []u8 offset : u64 File Io/Dispatch.zig: 3524
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558 fn fileReadPositional (
userdata : ?*anyopaque ,
file : File ,
data : []const []u8 ,
offset : u64 ,
) File .ReadPositionalError !usize {
const ev : *Evented = @ptrCast (@alignCast (userdata ));
_ = ev ;
var iovecs : [max_iovecs_len ]iovec = undefined ;
var iovlen : iovlen_t = 0 ;
var remaining : Io .Limit = .unlimited ;
for (data ) |buf | addBuf (false , &iovecs , &iovlen , &remaining , buf );
if (iovlen == 0 ) return 0 ;
while (true ) {
const rc = c .preadv (file .handle , &iovecs , iovlen , @bitCast (offset ));
switch (c .errno (rc )) {
.SUCCESS => return @intCast (rc ),
.INTR => {},
.NXIO => return error .Unseekable ,
.SPIPE => return error .Unseekable ,
.OVERFLOW => return error .Unseekable ,
.NOBUFS => return error .SystemResources ,
.NOMEM => return error .SystemResources ,
.AGAIN => return error .WouldBlock ,
.IO => return error .InputOutput ,
.ISDIR => return error .IsDir ,
.NOTCONN => |err | return errnoBug (err ), // not a socket
.CONNRESET => |err | return errnoBug (err ), // not a socket
.INVAL => |err | return errnoBug (err ),
.FAULT => |err | return errnoBug (err ),
.BADF => return error .NotOpenForReading ,
else => |err | return unexpectedErrno (err ),
}
}
}