class Amber::Pipe::Compression::Deflater

Overview

One raw DEFLATE stream whose zlib state and output buffer live outside the garbage-collected heap, so it can compress one response after another without allocating.

It uses the settings Compress::Deflate::Writer uses (raw DEFLATE, 15 window bits, memory level 8, the default strategy), so its output is byte for byte the same.

:nodoc:

Defined in:

amber/pipes/compression/deflater.cr

Constant Summary

OUTPUT_BUFFER_BYTES = 8192

Constructors

Instance Method Summary

Constructor Detail

def self.new(level : Int32) #

[View source]

Instance Method Detail

def finalize #

A compressor dropped without #release (a response that never closed) still frees its memory when it is collected.


[View source]
def finish(output : IO) : Nil #

Ends the stream and writes its last bytes.


[View source]
def flush(output : IO) : Nil #

Writes everything compressed so far, ending on a byte boundary.


[View source]
def release : Nil #

Frees the zlib state and the output buffer.


[View source]
def reset : Nil #

Readies the stream for the next response, keeping its memory.


[View source]
def write(slice : Bytes, output : IO) : Nil #

Compresses slice into output, keeping zlib's own buffering.


[View source]