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 library itself.
pubconstServer = struct {
socket: Socket,
options: AcceptOptions,
pubfndeinit(s: *Server, io: Io) void {
s.socket.close(io);
s.* = undefined;
}
pubconstAcceptError = error{
/// The per-process limit on the number of open file descriptors has been reached.ProcessFdQuotaExceeded,
/// The system-wide limit on the total number of open files has been reached.SystemFdQuotaExceeded,
/// Not enough free memory. This often means that the memory allocation is limited/// by the socket buffer limits, not by the system memory.SystemResources,
/// Either `listen` was never called, or `shutdown` was called (possibly while/// this call was blocking). This allows `shutdown` to be used as a concurrent/// cancellation mechanism.SocketNotListening,
/// The network subsystem has failed.NetworkDown,
/// No connection is already queued and ready to be accepted, and/// the socket is configured as non-blocking.WouldBlock,
/// An incoming connection was indicated, but was subsequently terminated by the/// remote peer prior to accepting the call.ConnectionAborted,
/// Firewall rules forbid connection.BlockedByFirewall,
ProtocolFailure,
} || Io.UnexpectedError || Io.Cancelable;
pubconstAcceptOptions = switch (native_os) {
.windows => struct { mode: Socket.Mode, protocol: ?Protocol },
else => void,
};
/// Blocks until a client connects to the server.pubfnaccept(s: *Server, io: Io) AcceptError!Stream {
return .{ .socket = tryio.vtable.netAccept(io.userdata, s.socket.handle, s.options) };
}
}