Core concepts
Hokusai is built on three ideas.
- Immutable. Every operation returns a new
Hokusaivalue; the source pipeline is unchanged and can be reused or branched across tasks. - Deferred. Building a pipeline only records what to do. The image is opened and processed when a terminal,
data()orwrite(to:), runs, so decode and pixel-dependent errors are thrown there. Option validation (dimensions, quality, colours) still happens immediately. - Ordered. A pipeline means exactly the operations you wrote, in the order you wrote them. Hokusai may change how it runs them, never what they produce: it does not reorder operations, fuse resizes or keep results between evaluations.
Terminals run the blocking native work off Swift’s cooperative executor. Cancelling the calling task stops the work and throws CancellationError.