zlib

    MoonBit zlib: provide simplified zlib format compressed data.

    zlib
    algorithm
    compress
    moonbit
    Download zip
    Author
    Version
    0.21.13
    License
    Apache-2.0
    Last updated
    3 days ago
    Downloads
    31K

    Dependencies

    #gmlewis/zlib

    check

    This is a simplified zlib format compressed data package based on Go's implementation: https://cs.opensource.google/go/go/+/refs/tags/go1.23.3:src/compress/zlib/reader.go which has the copyright notice:

    // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file.

    #Status

    The code has been updated to support compiler:

    $ moon version --all moon 0.1.20260827 (d0aaa07 2026-08-27) ~/.moon/bin/moon moonc v0.10.11+6ff76a5f9 (2026-08-28) ~/.moon/bin/moonc moonrun 0.1.20260827 (d0aaa07 2026-08-27) ~/.moon/bin/moonrun

    Resetter

    pub(open) trait Resetter {
    fn reset(Self, &
    Reader
    ,
    Slice
    [Byte]) ->
    IOError
    ?
    }

    Resetter resets a ReadCloser returned by [Reader::new] or [Reader::new_dict] to switch to a new underlying Reader. This permits reusing a ReadCloser instead of allocating a new one.

    Reader

    type Reader

    impl Closer for Reader
    impl Reader for Reader

    Reader::new

    Reader::new creates a new ReadCloser. Reads from the returned ReadCloser read and decompress data from r. If r does not implement [io.ByteReader], the decompressor may read more data than necessary from r. It is the caller's responsibility to call close on the ReadCloser when done.

    The [io.ReadCloser] returned by Reader::new also implements [Resetter].

    Reader::new_dict

    Reader::new_dict is like [Reader::new] but uses a preset dictionary. Reader::new_dict ignores the dictionary if the compressed data does not refer to it. If the compressed data refers to a different dictionary, Reader::new_dict returns [err_dictionary].

    The ReadCloser returned by Reader::new_dict also implements [Resetter].

    Writer

    type Writer

    impl Writer for Writer

    Writer::flush

    Writer::new

    Writer::new_dict

    fn Writer::new_dict(w : &
    Writer
    , dict :
    Slice
    [Byte]) -> Writer

    Writer::reset

    fn Writer::reset(self : Writer, w : &
    Writer
    ) -> Unit

    err_checksum

    let err_checksum :
    IOError

    err_checksum is returned when reading ZLIB data that has an invalid checksum.

    err_dictionary

    let err_dictionary :
    IOError

    err_dictionary is returned when reading ZLIB data that has an invalid dictionary.

    err_header

    err_header is returned when reading ZLIB data that has an invalid header.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io