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 ¶
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.