Skip to content

std/deflate ​

Pure-Milo DEFLATE compression (RFC 1951) plus the gzip (RFC 1952) and zlib (RFC 1950) container framings. No external codec dependency. Decompress with std/inflate.

milo
from "std/deflate" import { Deflate }

Example ​

milo
from "std/inflate" import { Inflate }

let gz = Deflate.gzip("hello, hello, hello")
let back = Inflate.gzip(gz)!   // "hello, hello, hello"

API reference ​

BitW ​

milo
pub struct BitW

Fields:

  • acc: i64: bits accumulated for the current byte (LSB-first)
  • nbits: i64: how many bits are in acc (0..7)
  • out: string

Deflate ​

milo
pub struct Deflate

Deflate namespace — Deflate.raw (raw deflate), .gzip, .zlib compressors.

Deflate.gzip ​

milo
fn Deflate.gzip(src: &string): string

Compress to a gzip stream: 10-byte header, DEFLATE body, CRC-32 + length trailer.

Deflate.raw ​

milo
fn Deflate.raw(src: &string): string

Compress to a single fixed-Huffman DEFLATE stream (no container header).

Deflate.zlib ​

milo
fn Deflate.zlib(src: &string): string

Compress to a zlib stream: 2-byte header, DEFLATE body, Adler-32 trailer.