moonbitlang/core/compress/gzip does not have a README file

    DeflateAction

    Requested action for one streaming compression step.

    The action applies after the complete input view has been consumed. If a step reports partial consumption, re-present the remaining suffix with the same action.

    Status

    Outcome of one step of the streaming DEFLATE state machine.

    The engine is runtime-agnostic: it moves bytes between an input view and an output buffer and suspends by returning one of these, so any driver — a synchronous loop or an async adapter — can resume it.

    StepResult

    Result of one streaming codec call. The counts describe the input prefix accepted and the output prefix written by this call, including when it returns Done. Keep the result to inspect it independently of later calls.

    Strategy

    Whole-buffer compression strategy. Levels are clamped to 0-9; level 0 emits stored blocks only.

    GzipError

    pub suberror GzipError {
    GzipError(GzipErrorKind, String)
    }

    Structured gzip decoding failure: a stable category plus a human-readable diagnostic.

    Decoder

    type Decoder

    Streaming gzip decompressor (RFC 1952). Feed compressed input and drain plaintext with step; it verifies the CRC-32 and length trailer. Binds no I/O trait.

    Decoder::Decoder

    fn Decoder::Decoder(multistream? : Bool) -> Decoder

    Create a fresh gzip decompressor. With the default multistream=true, adjacent RFC 1952 members are decoded as one logical stream. Set it to false for a framed transport that must stop after the first member and recover accepted read-ahead through unused_input(). Unaccepted bytes remain with the caller, as reported by result.consumed.

    Decoder::check_end

    Declare EOF after all input is accepted; NeedMoreOutput requires draining with step.

    Decoder::is_finished

    fn Decoder::is_finished(self : Decoder) -> Bool

    Whether the whole gzip stream has been decoded and its trailer verified.

    Decoder::step

    fn Decoder::step(self : Decoder, input : BytesView, output : MutArrayView[Byte]) ->
    StepResult
    raise GzipError

    Run one decompression step. Accepts a bounded prefix of input, then decodes plaintext into output. Returns StepResult with this call's status, consumed and produced byte counts; drop only input[:result.consumed] and re-present a suffix that was held back by output backpressure. Pending body input is drained before accepting more, so a call can produce output without consuming new input. Input is borrowed only for this call; any retained suffix is copied. Once all source input has been accepted, call check_end to declare EOF. It returns Done, requests output space, or raises a truncation error. Drain pending output through step with empty input; EOF stays latched. A multi-member stream needs this signal to establish that no further member will follow. After EOF or Done, later input is not accepted. Concatenated multi-member streams (RFC 1952 §2.2) decode in full; their payloads are joined. If the final accepted view also contains non-gzip bytes, retrieve that read-ahead after Done with unused_input(). On failure, the decoder locks the first GzipError kind/message and rethrows it on every later call. A failing call returns no result; its output buffer may already contain partial output.

    Decoder::unused_input

    fn Decoder::unused_input(self : Decoder) -> Bytes

    Bytes accepted by step beyond the final completed gzip member.

    A buffered sync reader or async transport can deliver a member trailer and bytes from the next protocol frame in one read. Once Done is reached, this method returns that read-ahead suffix. It is empty before completion and when the gzip stream ended exactly at the input boundary.

    Encoder

    type Encoder

    Streaming gzip compressor.

    Encoder::Encoder

    fn Encoder::Encoder(level? : Int, fast_store? : Bool) -> Encoder

    Create a fresh gzip compressor. level 0-9 (clamped) trades speed for ratio; 0 = stored only, 6 = default. Opt-in fast_store samples each block; it may increase output size. The default is false.

    Encoder::is_finished

    fn Encoder::is_finished(self : Encoder) -> Bool

    Whether the complete gzip stream has been emitted.

    Encoder::reset

    fn Encoder::reset(self : Encoder) -> Unit

    Start a fresh gzip stream, preserving compression options and reusing buffers.

    Encoder::step

    Run one compression step. Accepts a bounded prefix of input (folding only that prefix into CRC-32 and ISIZE), then drains gzip output into output. Returns StepResult with this call's status, consumed and produced byte counts. Drop only input[:result.consumed]: output backpressure may make a large input partially consumed. Re-present its suffix with the same action; once the complete view is accepted, SyncFlush or Finish remains sticky across header and body backpressure. After finalization, later input is not accepted and result.consumed is zero.

    GzipErrorKind

    pub(all) enum GzipErrorKind {
    Truncated
    InvalidHeader
    InvalidDeflate
    ChecksumMismatch
    LengthMismatch
    OutputLimitExceeded(limit~ : UInt64, observed~ : UInt64)
    Cancelled
    InvalidArgument
    } derive(Eq,
    Debug
    )

    Machine-readable category for a gzip decoding failure. The accompanying GzipError message remains intended for diagnostics rather than branching. Output limits, cancellation and invalid limits apply to decompress only.

    GzipErrorKind::equal

    compress

    fn compress(input : BytesView, strategy? :
    Strategy
    , fast_store? : Bool) -> Bytes

    Compress a complete gzip stream with the selected DEFLATE strategy. fast_store may bypass the strategy for sampled inputs, trading ratio for speed.

    decompress

    fn decompress(input : BytesView, max_output? : Int, cancelled? : () -> Bool) -> Bytes raise GzipError

    Decode and join gzip members, verifying each CRC-32 and length trailer. Trailing bytes that do not begin another member are ignored. max_output caps cumulative output (default: Bytes capacity); exceeding it raises OutputLimitExceeded(limit~, observed~), a negative value InvalidArgument. cancelled is polled at entry, between members and in 4 KiB intervals during name/comment scanning, decoding, checksumming and joining; true raises Cancelled.