2022-01-27 11:55:55 +01:00
2022-01-27 11:55:55 +01:00
2020-01-25 12:21:01 +01:00
2021-01-19 13:03:03 +01:00
2020-01-25 16:38:23 +01:00
2022-01-27 11:55:55 +01:00
2022-01-27 11:55:55 +01:00
2022-01-27 11:55:55 +01:00

zlib.carp

is a high-level wrapper around zlib.

Installation

(load "git@git.veitheller.de:carpentry/zlib.git@0.0.2")

Usage

The ZLib module provides only two functions, inflate and deflate. These functions work in tandem to provide you with data compression.

; deflate returns a Result of either binary data or an error message
(let [deflated (ZLib.deflate "mystring")]
  (match deflated
    ; inflate returns a Result of either a string or an error message
    (Success bin) (println* &(inflate bin))
    (Error msg) (IO.errorln &msg)))

Because its a Result type, we can apply combinators to it.

(=> (ZLib.deflate "mystring")
    (Result.and-then &ZLib.inflate)
    (Result.map-error &(fn [msg] (do (println* &msg) msg)))
)

You can also choose different levels of compression using deflate-with. The levels are defined in ZLib.ZLevel, and are NoCompression, BestSpeed, BestCompression, and DefaultCompression, which is, well, the default.


Have fun!

Description
a high-level wrapper around ZLib.
https://veitheller.de/zlib
Readme 35 KiB
Languages
C 100%