# deflate API reference

> The `deflate` package, from deflate 0.1.3, as published on mojoshelf (commit 6639b18c58fa), by `mojo doc` from Mojo 1.2.0.

## Modules

- [deflate.gzip](https://magmalake.dev/s/deflate/api/gzip.md): gzip (RFC 1952) framing over the raw DEFLATE in `raw.mojo`.
- [deflate.raw](https://magmalake.dev/s/deflate/api/raw.md): Raw DEFLATE (RFC 1951) — `inflate` and `deflate`, in pure Mojo.

DEFLATE (RFC 1951) and gzip (RFC 1952) in pure Mojo — no FFI, no dependencies.

`deflate` compresses, `inflate` decompresses, and `inflate_at` decompresses
one stream out of several laid back to back, reporting where it ended.
`gunzip` decodes a `.gz` file (every member, CRC-32 and length checked),
`gunzip_at` one member of it, and `gzip` writes one.

```mojo
from deflate import deflate, inflate

var packed = deflate(Span(data))    # List[UInt8], raw DEFLATE
var back = inflate(Span(packed))    # List[UInt8], == data
```

`inflate` and `deflate` streams are *raw*: no zlib (RFC 1950) header, no
gzip wrapper, no trailing checksum. Avro's `deflate` block codec is raw and
needs nothing more; gzip files go through `gunzip`.
