compress

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package compress is the one opinion about zstd this repo holds.

internal/wire stays stdlib-only so the framed protocol cannot drift by acquiring a dependency, and there is no zstd in the standard library — so the compressing wrap lives one package over, shared by every path that ships a tar stream: any blob a content-addressed store holds. Compression here is a transparent stream wrapper: what comes out of a Reader is byte-for-byte what went into a Writer, so the digest contract stays owned by the tar codec alone.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewReader

func NewReader(r io.Reader) (io.ReadCloser, error)

NewReader wraps r in a zstd decoder. Close releases it; concurrency 1 for the same reason as NewWriter.

WithDecoderMaxMemory and not WithDecoderMaxWindow: when streaming it caps the window too, and also the content size a single-segment frame uses as its window, which the max-window check never sees.

func NewWriter

func NewWriter(w io.Writer) (io.WriteCloser, error)

NewWriter wraps w in a zstd encoder. Close it to finish the stream — an unclosed encoder is a truncated frame the far end cannot decode.

Concurrency 1, deliberately: encoding happens on the calling goroutine, so an abandoned encoder on an error path leaks nothing for goleak to find.

func Pack

func Pack(w io.Writer, compressed bool, fn func(io.Writer) error) error

Pack writes one stream through fn, zstd-wrapped when compressed says so. The Close that finishes a zstd frame is part of packing rather than cleanup — an unclosed encoder is a truncated stream the far end cannot decode — which is why the wrap lives here once instead of at every call site that ships a tree.

func Unpack

func Unpack(r io.Reader, compressed bool, fn func(io.Reader) error) error

Unpack reads one stream through fn, zstd-unwrapped when compressed says so.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL