1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 <title>The Browseable Zig Standard Library</title>
7 <meta property="og:title" content="The Browseable Zig Standard Library" />
8 <meta property="og:type" content="website" />
9 <meta property="og:description" content="An HTML guide with a human-written catalog and pretty-printed source pages for reading." />
10 <meta property="og:url" content="http://ratfactor.com/zig/stdlib-browseable2/" />
11 <meta property="og:image" content="http://ratfactor.com/zig/stdlib-browseable2/zig-stdlib-book.svg" />
12 <style>
13 header { text-align: center; }
14 h1 { color: #777; }
15 h2 { color: #864; margin: 0; border-bottom: 1px solid #864; }
16 /* section { border: 2px solid tan; max-width: 400px; float: left; margin: 1em; padding: 1em; } */
17 a { font-size: 1.2em; background-color: #f1f1ff; }
18 a.normal-link { font-size: initial; background-color: transparent; }
19 code { background-color: #fff0d0; }
20 ul { margin: 0; }
21 /* Multi-column layout */
22 .container {
23 border-top: 2px solid #777;
24 column-width: 25em;
25 padding-top: 1em;
26 }
27 section {
28 border: 2px solid tan;
29 padding: 1em;
30 break-inside: avoid;
31 }
32 </style>
33 </head>
34 <body>
35 <header>
36 <img src="zig-stdlib-book.svg" alt="vector drawing of a book with zig logo">
37 <h1>The Zig Standard Library</h1>
38 </header>
39
40 <div class="container">
41
42 <section>
43 <p>This page contains a human-curated directory for the Zig standard
44 library. All *.zig links point to HTML documents which have been
45 automatically generated from the library source.</p>
46 <p>The files are split into two columns: The right column is the raw Zig
47 source code in the file. The left column will contain public identifiers
48 and any document comments to explain them.</p>
49 </section>
50
51 <section>
52 <h2>Data structures</h2>
53
54 <p>
55 <a href="array_list.zig.html">array_list.zig</a>
56 Probably the most commonly used data structure in Zig. This is a
57 resizeable list. Contains a huge number of handy methods for
58 manipulating a list.
59 See <a class="normal-link" href="https://ziglearn.org/chapter-2/#arraylist">Standard Patterns: ArrayList</a>
60 (ziglearn.org).
61 </p>
62 <p>
63 <a href="bounded_array.zig.html">bounded_array.zig</a>
64 For fixed-size lists. Compare with ArrayList.
65 </p>
66 <p>
67 <a href="multi_array_list.zig.html">multi_array_list.zig</a>
68 A list of structs, but stores the fields of the structs efficiently as
69 contiguous lists. See
70 <a class="normal-link" href="https://zig.news/kristoff/struct-of-arrays-soa-in-zig-easy-in-userland-40m0">Struct of Arrays (SoA) in Zig? Easy & in Userland!</a>
71 (zig.news).
72 </p>
73 <p>
74 <a href="array_hash_map.zig.html">array_hash_map.zig</a>
75 A "hash" or "dictionary" storing values by hashed key.
76 For typical needs, consider <code>StringHashMap</code>
77 or <code>AutoHashMap</code>.
78 See <a class="normal-link" href="https://devlog.hexops.com/2022/zig-hashmaps-explained/">Zig hashmaps explained</a> (hexops.com).
79 <br>
80 <a href="buf_map.zig.html">buf_map.zig</a>
81 A StringHashMap that copies and frees keys and values for you!
82 <br>
83 <a href="buf_set.zig.html">buf_set.zig</a>
84 A StringHashMap that works as a set of strings.
85 <br>
86 <a href="comptime_string_map.zig.html">comptime_string_map.zig</a>
87 Basically a StringHashMap that hashes at comptime!
88 </p>
89 <p>
90 <a href="enums.zig.html">enums.zig</a>
91 Functions for working with Zig's <code>enum</code>s.
92 </p>
93 <p>
94 <a href="fifo.zig.html">fifo.zig</a>
95 and
96 <a href="priority_dequeue.zig.html">priority_dequeue.zig</a>
97 and
98 <a href="priority_queue.zig.html">priority_queue.zig</a>
99 General-purpose queue structures with handy methods.
100 </p>
101 <p>
102 <a href="BitStack.zig.html">BitStack.zig</a>
103 An <code>ArrayList</code> of bits with stack methods like
104 <code>push()</code> and <code>pop()</code>. See
105 </p>
106 <p>
107 <a href="RingBuffer.zig.html">RingBuffer.zig</a>
108 A circular buffer with a backing slice with read/write
109 and slicing operations.
110 </p>
111 <p>
112 <a href="linked_list.zig.html">linked_list.zig</a>
113 Contains <code>SinglyLinkedList()</code> and
114 <code>DoublyLinkedList()</code> linked list types.
115 </p>
116 <p>
117 <a href="treap.zig.html">treap.zig</a>
118 A <a class="normal-link" href="https://en.wikipedia.org/wiki/Treap">treap</a>
119 (wikipedia.org) binary search tree.
120 </p>
121 <p>
122 <a href="packed_int_array.zig.html">packed_int_array.zig</a>
123 Read and write integers packed into memory like sardines.
124 </p>
125 <p>
126 <a href="bit_set.zig.html">bit_set.zig</a>
127 Bit sets let you manipulate the individual bits of your bytes. This file
128 contains multiple bit set types and has good descriptions of each.
129 </p>
130 <p>
131 <b>See also:</b> <code>atomic.zig</code> under Parallel and concurrent execution.
132 </p>
133 </section>
134
135 <section>
136 <h2>Zig-specific</h2>
137
138 <p>
139 <a href="std.zig.html">std.zig</a>
140 The starting point for the whole standard library. This is what
141 gets included when you do <code>const std = @import("std");</code>.
142 Imports the rest of the namespace. You can start here to browse
143 most of the library in this HTML version.
144 </p>
145 <p>
146 <a href="zig.zig.html">zig.zig</a>
147 Zig code tokenzing, parsing, abstract syntax tree, etc.
148 <i>Zig in Zig so you can Zig while you Zig.</i>
149 </p>
150 <p>
151 <a href="meta.zig.html">meta.zig</a>
152 Comptime introspection for Zig data types. (Get the fields from
153 a struct, for example).
154 </p>
155 <p>
156 <a href="testing.zig.html">testing.zig</a>
157 A bunch of helpful functions (and even an allocator that fails
158 on purpose) for your <code>test</code> blocks.
159 </p>
160 <p>
161 <a href="debug.zig.html">debug.zig</a>
162 Contains helpful functions such as
163 <code>std.debug.print()</code>,
164 <code>assert()</code>, <code>panic()</code>, and
165 <code>dumpCurrentStackTrace()</code>.
166 </p>
167 <p>
168 <a href="Build.zig.html">Build.zig</a>
169 Zig's build API provides functionality to
170 perform just about any compilation or file manipulation tasks you
171 might need to build a project. (You typically call its features from
172 a <code>build.zig</code> file.)
173 </p>
174 <p>
175 <a href="builtin.zig.html">builtin.zig</a>
176 All sorts of meta Zig stuff. Contains types returned by the
177 builtin functions (<code>@foo()</code>).
178 </p>
179 </section>
180
181 <section>
182 <h2>Memory and allocation</h2>
183
184 <p>
185 <a href="mem.zig.html">mem.zig</a>
186 Contains lots of functions for manipulating memory such as
187 <code>sort()</code>,
188 <code>eql()</code>,
189 <code>indexOfDiff()</code>,
190 <code>sliceTo()</code>,
191 <code>len()</code>,
192 <code>trim()</code>,
193 <code>indexOf()</code>,
194 <code>indexOfAny()</code>,
195 <code>indexOfNone()</code>,
196 <code>readIntNative()</code>,
197 <code>writeIntNative()</code>,
198 <code>tokenizeSequence()</code>,
199 <code>splitSequence()</code>,
200 <code>SplitIterator()</code>,
201 <code>alignInSlice()</code>,
202 and many more.
203 </p>
204 <p>
205 <a href="mem/Allocator.zig.html">mem/Allocator.zig</a>
206 Contains the interface used by all memory allocation features in
207 the Zig standard library.
208 </p>
209 <p>
210 <a href="heap.zig.html">heap.zig</a>
211 Defines many allocation strategies for managing memory
212 including
213 <a href="heap/general_purpose_allocator.zig.html">heap/general_purpose_allocator.zig</a>,
214 <a href="heap/PageAllocator.zig.html">heap/PageAllocator.zig</a>,
215 <a href="heap/arena_allocator.zig.html">heap/arena_allocator.zig</a>,
216 and
217 <a href="heap/memory_pool.zig.html">heap/memory_pool.zig</a>.
218 </p>
219 See
220 <ul>
221 <li><a class="normal-link" href="https://ziglearn.org/chapter-2/">Allocators</a>
222 (ziglearn.org)</li>
223 <li><a class="normal-link" href="https://www.openmymind.net/learning_zig/heap_memory/">Heap Memory and Allocators</a>
224 (openmymind.net)</li>
225 <li><a class="normal-link" href="https://www.huy.rocks/everyday/01-05-2022-zig-where-data-is-stored-and-how-to-choose-an-allocator">Where data is stored and how to choose an allocator</a>
226 (huy.rocks)</li>
227 </ul>
228 </section>
229
230 <section>
231 <h2>General utilities</h2>
232
233 <p>
234 <a href="fmt.zig.html">fmt.zig</a>
235 String formatting (this is how <code>print()</code> works), number
236 parsing, etc.
237 <b>TODO:</b> I need to make a "zig fmt by example" page.
238 </p>
239 <p>
240 <a href="io.zig.html">io.zig</a>
241 Input/Output support for reading and writing data.
242 Includes
243 <a href="io/Reader.zig.html">io/Reader.zig</a>,
244 <a href="io/writer.zig.html">io/writer.zig</a>,
245 <a href="io/bit_reader.zig.html">io/bit_reader.zig</a>,
246 <a href="io/bit_writer.zig.html">io/bit_writer.zig</a>,
247 <a href="io/buffered_reader.zig.html">io/buffered_reader.zig</a>,
248 <a href="io/buffered_writer.zig.html">io/buffered_writer.zig</a>,
249 and
250 <a href="io/tty.zig.html">io/tty.zig</a>.
251 </p>
252 <p>
253 <a href="log.zig.html">log.zig</a>
254 Standardized logging with support for levels (<code>err</code>,
255 <code>warn</code>, <code>info</code>, <code>debug</code>).
256 </p>
257 <p>
258 <a href="Progress.zig.html">Progress.zig</a>
259 Terminal progress indicator (uses ANSI escape sequences when possible).
260 </p>
261 <p>
262 <a href="sort.zig.html">sort.zig</a>
263 Sorting and searching algorithms such as
264 <code>insertion()</code>,
265 <code>heap()</code>,
266 <code>binarySearch()</code>,
267 <code>min()</code>,
268 and
269 <code>max()</code>.
270 </p>
271 <p>
272 <a href="json.zig.html">json.zig</a>
273 Read and write data to and from the JSON serialization format.
274 </p>
275 <p>
276 <a href="Ini.zig.html">Ini.zig</a>
277 Read INI (<code>*.ini</code>) formatted configuration files.
278 </p>
279 <p>
280 <a href="tar.zig.html">tar.zig</a>
281 Support for the
282 <a class="normal-link" href="https://en.wikipedia.org/wiki/Tar_(computing)">Tar</a>
283 (wikipedia.org) archive file format.
284 </p>
285 <p>
286 <a href="crypto.zig.html">crypto.zig</a>
287 A huge number of cryptographic functions.
288 <br>
289 <b>Hashes</b>: <a href="crypto/md5.zig.html">crypto/md5.zig</a>,
290 <a href="crypto/sha1.zig.html">crypto/sha1.zig</a>,
291 <a href="crypto/sha2.zig.html">crypto/sha2.zig</a>,
292 <a href="crypto/sha3.zig.html">crypto/sha3.zig</a>,
293 <a href="crypto/bcrypt.zig.html">crypto/bcrypt.zig</a>,
294 <a href="crypto/scrypt.zig.html">crypto/scrypt.zig</a>,
295 and more.
296 <br>
297 <b>Cryptography</b>:
298 <a href="crypto/25519/curve25519.zig.html">crypto/25519/curve25519.zig</a>,
299 <a href="crypto/25519/ed25519.zig.html">crypto/25519/ed25519.zig</a>,
300 <a href="crypto/aes.zig.html">crypto/aes.zig</a>,
301 and more.
302 <br>
303 <b>See also:</b> <code>crypto/tls.zig</code> and <code>crypto/Certificate.zig</code>
304 under Networking.
305 </p>
306 <p>
307 <a href="hash.zig.html">hash.zig</a>
308 More general hashing algorithms.
309 </p>
310 <p>
311 <a href="rand.zig.html">rand.zig</a>
312 Fast and/or cryptographically secure pseudo-random number generators.
313 </p>
314 <p>
315 <a href="leb128.zig.html">leb128.zig</a>
316 Read and write
317 <a class="normal-link" href="https://en.wikipedia.org/wiki/LEB128">LEB128</a>
318 (wikipedia.org) Little Endian Base 128 numbers.
319 </p>
320 <p>
321 <a href="SemanticVersion.zig.html">SemanticVersion.zig</a>
322 Read (parse), write, and sort semantic version numbers.
323 </p>
324 <p>
325 <a href="unicode.zig.html">unicode.zig</a>
326 Functions for handling encoded Unicode sequences:
327 <code>utf8Encode()</code>,
328 <code>utf8Decode()</code>,
329 <code>utf8ValidateSlice()</code>,
330 <code>utf16leToUtf8Alloc()</code>,
331 etc.
332 </p>
333 <p>
334 <a href="ascii.zig.html">ascii.zig</a>
335 Handy functions for testing <code>u8</code> values as 7-bit ASCII
336 characters (<code>isAlphabetic()</code>, <code>toUpper()</code>, etc.
337 </p>
338 <p>
339 <a href="base64.zig.html">base64.zig</a>
340 Encode and decode
341 <a class="normal-link" href="https://en.wikipedia.org/wiki/Base64">Base64</a>
342 (wikipedia.org) data.
343 </p>
344 <p>
345 <a href="c.zig.html">c.zig</a>
346 Utilities for interoperating with C code. Also contains a lot of
347 OS and architecture-specific function implementations.
348 (See a partial list under OS.)
349 </p>
350 <p>
351 <a href="time/epoch.zig.html">time/epoch.zig</a>
352 Important dates for common OSs and some simple date calculations.
353 </p>
354 <p>
355 <a href="tz.zig.html">tz.zig</a>
356 Handle Earth timezone files.
357 </p>
358 <p>
359 <a href="compress.zig.html">compress.zig</a>
360 Contains a large number of compression/decompression algorithms such
361 as
362 <a href="compress/gzip.zig.html">compress/gzip.zig</a>,
363 <a href="compress/xz.zig.html">compress/xz.zig</a>,
364 <a href="compress/zlib.zig.html">compress/zlib.zig</a>, and more!
365 </p>
366 <p>
367 <a href="math.zig.html">math.zig</a>
368 General mathematical operations.
369 </p>
370 <p>
371 <a href="simd.zig.html">simd.zig</a>
372 Functions for working with SIMD (Single Instruction; Multiple Data),
373 if hardware support is present.
374 </p>
375 <p>
376 <a href="valgrind.zig.html">valgrind.zig</a>
377 Support for working with the
378 <a class="normal-link" href="https://en.wikipedia.org/wiki/Valgrind">Valgrind</a>
379 memory leak detection and profiling tool.
380 </p>
381 </section>
382
383 <section>
384 <h2>OS and architecture-specific</h2>
385
386 <p>
387 <a href="os.zig.html">os.zig</a>
388 Wrappers for a very large list of OS-specific functions. Includes
389 Unix-like, Emscripten, WASI, Plan9, UEFI, and Windows.
390 </p>
391 <p>
392 <a href="target.zig.html">target.zig</a>
393 Functionality for building Zig programs for a big list of
394 processor architectures.
395 </p>
396 <p>
397 <a href="process.zig.html">process.zig</a>
398 Environment information, etc. for processes (e.g. current working
399 directory and environment variables).
400 </p>
401 <p>
402 <a href="time.zig.html">time.zig</a>
403 Get time, measure time, and sleep.
404 </p>
405 <p>
406 <a href="start.zig.html">start.zig</a>
407 The <code>start()</code> function for executable files. Handles
408 OS-specific startup tasks.
409 </p>
410 <p>
411 <a href="elf.zig.html">elf.zig</a>
412 Support for the
413 <a class="normal-link" href="https://en.wikipedia.org/wiki/Executable_and_Linkable_Format">ELF</a>
414 (wikipedia.org) executable format.
415 </p>
416 <p>
417 <a href="coff.zig.html">coff.zig</a>
418 Support for the
419 <a class="normal-link" href="https://en.wikipedia.org/wiki/COFF">COFF</a>
420 (wikipedia.org) executable format.
421 </p>
422 <p>
423 <a href="macho.zig.html">macho.zig</a>
424 Support for the
425 <a class="normal-link" href="https://en.wikipedia.org/wiki/Mach-O">Mach-O</a>
426 (wikipedia.org) executable format.
427 </p>
428 <p>
429 <a href="dwarf.zig.html">dwarf.zig</a>
430 Support for the
431 <a class="normal-link" href="https://en.wikipedia.org/wiki/DWARF">DWARF</a>
432 (wikipedia.org) debugging data format.
433 </p>
434 <p>
435 <a href="pdb.zig.html">pdb.zig</a>
436 Support for the
437 <a class="normal-link" href="https://en.wikipedia.org/wiki/Program_database">PDB</a>
438 (wikipedia.org) debugging data format.
439 </p>
440 <p>
441 <a href="wasm.zig.html">wasm.zig</a>
442 WASM opcode list and functions.
443 </p>
444 <p>
445 <a href="Thread.zig.html">Thread.zig</a>
446 Native operating system thread support.
447 </p>
448 <p>
449 <a href="child_process.zig.html">child_process.zig</a>
450 Native child process spawning support.
451 </p>
452 <p>
453 <a href="dynamic_library.zig.html">dynamic_library.zig</a>
454 Utilities for working with dynamic libraries (.dll, .so, etc.)
455 </p>
456 <p>
457 <a href="fs.zig.html">fs.zig</a>
458 File system support.
459 Contains
460 <a href="fs/file.zig.html">fs/file.zig</a>,
461 <a href="fs/path.zig.html">fs/path.zig</a>,
462 <a href="fs/wasi.zig.html">fs/wasi.zig</a>,
463 and
464 <a href="fs/watch.zig.html">fs/watch.zig</a>.
465 </p>
466 <p>
467 <b>See also:</b> the C-code files such as
468 <a href="c/linux.zig.html">c/linux.zig</a>,
469 <a href="c/openbsd.zig.html">c/openbsd.zig</a>,
470 <a href="c/freebsd.zig.html">c/freebsd.zig</a>,
471 <a href="c/netbsd.zig.html">c/netbsd.zig</a>,
472 <a href="c/darwin.zig.html">c/darwin.zig</a>,
473 <a href="c/wasi.zig.html">c/wasi.zig</a>,
474 <a href="c/windows.zig.html">c/windows.zig</a>,
475 etc.
476 </section>
477
478 <section>
479 <h2>Parallel and concurrent execution</h2>
480
481 <p>
482 <a href="atomic.zig.html">atomic.zig</a> Support for atomic access to
483 shared memory. See specific data structures in
484 <a href="atomic/queue.zig.html">atomic/queue.zig</a>
485 and
486 <a href="atomic/stack.zig.html">atomic/stack.zig</a>.
487 </p>
488 <p>
489 <a href="once.zig.html">once.zig</a>
490 Executes a function just once.
491 </p>
492 <p>
493 <a href="event.zig.html">event.zig</a>
494 Support for various types of event-based programming.
495 <br>
496 Examples:
497 <a href="event/batch.zig.html">event/batch.zig</a>,
498 <a href="event/future.zig.html">event/future.zig</a>,
499 and
500 <a href="event/loop.zig.html">event/loop.zig</a>.
501 </p>
502 <p>
503 <b>See also:</b> <code>Thread.zig</code> and
504 <code>child_process.zig</code> under OS.
505 </p>
506 </section>
507
508 <section>
509 <h2>Networking</h2>
510
511 <p>
512 <a href="net.zig.html">net.zig</a>
513 Networking functions for TCP/IP, Unix Sockets, DNS, etc.
514 </p>
515 <p>
516 <a href="Uri.zig.html">Uri.zig</a><br>
517 Read and write (parse) URIs (see the tests in this one!).
518 </p>
519 <p>
520 <a href="crypto/tls.zig.html">crypto/tls.zig</a> and
521 <a href="crypto/Certificate.zig.html">crypto/Certificate.zig</a>
522 for cryptographic networking.
523 </p>
524 <p>
525 <a href="http.zig.html">http.zig</a>
526 HTTP support! Includes
527 <a href="http/Client.zig.html">http/Client.zig</a>,
528 <a href="http/Headers.zig.html">http/Headers.zig</a>,
529 and
530 <a href="http/Server.zig.html">http/Server.zig</a>.
531 </p>
532 </section>
533
534 </div> <!-- end .container -->
535
536 <footer>
537 This page is the entry point for the Zig Standard Library
538 source viewing utility,
539 <a href="http://ratfactor.com/repos/zstd-browse2/">zstd-browse2</a>.
540 </footer>
541 </body>
542 </html>