Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Treatment compress

compression/zlib::compress


Parameters

↳ var level: i32 = 6

Inputs

⇥ data: Stream<byte>

Outputs

↦ completed: Block<void>
↦ compressed: Stream<byte>
↦ error: Block<string>
↦ failed: Block<void>
↦ finished: Block<void>


Compresses data with zlib.

The bytes received through data are compressed with zlib at level, from 0 (no compression) to 9 (smallest), 6 by default, and given through compressed while they come, as one zlib stream.

Once data ends and everything is given, completed is emitted. If level is not supported or compression fails, failed is emitted and error contains the reason. finished is emitted in every case.

graph LR
     T("compress()")
     B["… 🟦 🟦 🟦"] -->|data| T

     T -->|compressed| O["… 🟪 🟪"]
     T -->|completed| C["〈🟩〉"]

     style B fill:#ffffff,stroke:#ffffff
     style O fill:#ffffff,stroke:#ffffff
     style C fill:#ffffff,stroke:#ffffff