Drivers | Zig | Program targets

Targets · Zig · Drivers

The native drivers that provide the interface, console and network.

How a Program becomes Zig, in parts. Start with the introduction, then follow each part into the rendered output and the runtime it links against.

A driver is a Zig struct with the driver's functions: it drains one context channel and reconciles the resources it owns. Here is a console driver — it drains the Console.Lines channel and prints each line that has changed since the last cycle.

A program lists the drivers it uses; the runtime opens a channel for each and never hardcodes one.

Each cycle the runtime opens the driver's channel, runs the reactive program (which emits into it), drains it, and passes the slice to dispatch :

A driver that produces events — a timer, a network reply — calls the add_updates it was given in init , which schedules the next cycle. The three shapes are the same as everywhere: a tree renderer (the terminal interface), a request set (network), and a shared ticker.

Recommended articles