flatecut

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package flatecut produces DEFLATE-formatted data subject to a maximum compressed size.

The typical compression problem is to encode all of the given source data in some number of bytes. This package's problem is finding a reasonably long prefix of the source data that encodes in up to a given number of bytes.

Index

Constants

View Source
const (
	// SmallestValidMaxEncodedLen is the length in bytes of the smallest valid
	// DEFLATE-encoded data.
	SmallestValidMaxEncodedLen = 2
)

Variables

This section is empty.

Functions

func Cut

func Cut(w io.Writer, encoded []byte, maxEncodedLen int) (encodedLen int, decodedLen int, retErr error)

Cut modifies encoded's contents such that encoded[:encodedLen] is valid DEFLATE-compressed data, assuming that encoded starts off containing valid DEFLATE-compressed data.

If a nil error is returned, then encodedLen <= maxEncodedLen will hold.

Decompressing that modified, shorter byte slice produces a prefix (of length decodedLen) of the decompression of the original, longer byte slice.

If w is non-nil, that prefix is also written to w. If a non-nil error is returned, incomplete data might still be written to w.

It does not necessarily return the largest possible decodedLen.

Types

This section is empty.

Jump to

Keyboard shortcuts

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