package ozstd

  1. Overview
  2. Docs

Module Compressor.StreamSource

The compression stream module for incremental compression.

Sourcetype t
Sourceexception Already_closed

Raised when trying to compress a closed stream.

Sourceval create : ?dictionary:Dictionary.t -> ?level:int -> unit -> t

create ?dictionary ?level ()

Creates a new compression stream.

Sourceval of_context : Context.t -> t

of_context context

Creates a compression stream from the existing compression context.

Sourceval close : t -> unit

finish ()

Close the compression stream.

Compression

Sourceval compress : in_slice:Slice_bstr.t -> out_slice:Slice_bstr.t -> t -> [< `Continue | `End | `Flush ] -> remaining:int * consumed:int * compressed:int

compress ~in_buffer ~out_buffer stream mode

Compresses bytes from in_buffer into out_buffer buffer.

The mode argument controls the flushing behavior of the stream.

  • returns

    A labeled triple (~remaining, ~consumed, ~compressed) where:

    • remaining is the number of bytes remaining in the source;
    • consumed is the number of bytes consumed from in_buffer;
    • compressed is the number of compressed bytes written to out_buffer.

Buffers sizes

Sourceval in_size : unit -> int

in_size () returns the recommended size for the input compression buffer.

Sourceval out_size : unit -> int

out_size () returns the recommended size for the output compression buffer.