libzstd

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT, BSD-3-Clause Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

libzstd

Go translation of the Zstandard 1.5.7 decoder, altered from the original C sources of bitstream.h, entropy_common.c, fse_decompress.c, huf_decompress.c, zstd_decompress_block.c, zstd_decompress.c, zstd_ddict.c and the lib/legacy v0.5 to v0.7 decoders.

Documentation

Index

Constants

View Source
const ContentSizeError = lContentSizeError

ContentSizeError is ZSTD_CONTENTSIZE_ERROR, the decompressed bound of a frame that could not be sized

Variables

This section is empty.

Functions

func GetDecompressedSizeLegacy

func GetDecompressedSizeLegacy(src []byte) uint64

GetDecompressedSizeLegacy is the content size a legacy frame header declares, zero when it declares none

func IsLegacy

func IsLegacy(src []byte) uint32

IsLegacy reports the format version of a v0.5, v0.6 or v0.7 frame start, zero for anything else

Types

type DCtx

type DCtx struct {
	// contains filtered or unexported fields
}

DCtx is a ZSTD_DCtx and ZSTD_DStream of libzstd 1.5.7 built for x86-64 with BMI2 and legacy support from v0.5

func NewDStream

func NewDStream() *DCtx

NewDStream is ZSTD_createDStream, a decoder with default parameters waiting for a frame

func (*DCtx) Decompress

func (dc *DCtx) Decompress(dst, src []byte) (int, ErrorCode)

Decompress is ZSTD_decompressDCtx of src into dst with the referenced dictionary, the size decoded

func (*DCtx) DecompressStream

func (dc *DCtx) DecompressStream(out, in []byte, inPos int) (int, int, uint64, ErrorCode)

DecompressStream is ZSTD_decompressStream over out and in from inPos, the bytes written, input position and hint

func (*DCtx) DecompressUsingDDict

func (dc *DCtx) DecompressUsingDDict(dst, src []byte, d *DDict) (int, ErrorCode)

DecompressUsingDDict is ZSTD_decompress_usingDDict of src into dst, the size decoded

func (*DCtx) DecompressUsingDict

func (dc *DCtx) DecompressUsingDict(dst, src, dict []byte) (int, ErrorCode)

DecompressUsingDict is ZSTD_decompress_usingDict of src into dst, the size decoded

func (*DCtx) RefDDict

func (dc *DCtx) RefDDict(d *DDict) ErrorCode

RefDDict is ZSTD_DCtx_refDDict, using d for every following frame

func (*DCtx) ResetSession

func (dc *DCtx) ResetSession()

ResetSession is ZSTD_DCtx_reset with ZSTD_reset_session_only

type DDict

type DDict struct {
	// contains filtered or unexported fields
}

DDict is a ZSTD_DDict, a dictionary with its entropy tables digested

func (*DDict) DictID

func (d *DDict) DictID() uint32

DictID is ZSTD_getDictID_fromDDict

type DictContentType

type DictContentType int

DictContentType is ZSTD_dictContentType_e

const (
	DictContentAuto DictContentType = iota
	DictContentRaw
	DictContentFull
)

ZSTD_dct_auto, ZSTD_dct_rawContent and ZSTD_dct_fullDict

type ErrorCode

type ErrorCode int

ErrorCode is a ZSTD_ErrorCode, zero when nothing failed

const (
	ErrGeneric                     ErrorCode = 1
	ErrPrefixUnknown               ErrorCode = 10
	ErrVersionUnsupported          ErrorCode = 12
	ErrFrameParameterUnsupport     ErrorCode = 14
	ErrWindowTooLarge              ErrorCode = 16
	ErrCorruptionDetected          ErrorCode = 20
	ErrChecksumWrong               ErrorCode = 22
	ErrLiteralsHeaderWrong         ErrorCode = 24
	ErrDictionaryCorrupted         ErrorCode = 30
	ErrDictionaryWrong             ErrorCode = 32
	ErrTableLogTooLarge            ErrorCode = 44
	ErrMaxSymbolValueTooLarge      ErrorCode = 46
	ErrMaxSymbolValueTooSmall      ErrorCode = 48
	ErrStageWrong                  ErrorCode = 60
	ErrInitMissing                 ErrorCode = 62
	ErrMemoryAllocation            ErrorCode = 64
	ErrDstSizeTooSmall             ErrorCode = 70
	ErrSrcSizeWrong                ErrorCode = 72
	ErrNoForwardProgressDestFull   ErrorCode = 80
	ErrNoForwardProgressInputEmpty ErrorCode = 82
)

ZSTD_ErrorCode values the decoders raise

func DecompressLegacy

func DecompressLegacy(dst, src, dict []byte) (int, ErrorCode)

DecompressLegacy decodes one whole legacy frame with an optional dictionary into dst and returns the bytes written

func FindFrameCompressedSize

func FindFrameCompressedSize(src []byte) (int, ErrorCode)

FindFrameCompressedSize is ZSTD_findFrameCompressedSize, the compressed size of the frame starting src

func FindFrameSizeInfoLegacy

func FindFrameSizeInfoLegacy(src []byte) (compressedSize uint64, decompressedBound uint64, e ErrorCode)

FindFrameSizeInfoLegacy returns the compressed size of the legacy frame starting src and the bound of its content

func (ErrorCode) Error

func (e ErrorCode) Error() string

ERR_getErrorString text of the code

type LegacyStream

type LegacyStream struct {
	// contains filtered or unexported fields
}

LegacyStream is the buffered decoder ZSTD_initLegacyStream keeps for one legacy format version

func InitLegacyStream

func InitLegacyStream(prev *LegacyStream, prevVersion, newVersion uint32, dict []byte) *LegacyStream

InitLegacyStream readies the stream decoder of newVersion with dict, reusing prev when the version did not change

func (*LegacyStream) Decompress

func (s *LegacyStream) Decompress(version uint32, out, in []byte) (written, read int, hint uint64, e ErrorCode)

Decompress runs ZSTD_decompressLegacyStream, the bytes written to out and read from in then the next input hint

Jump to

Keyboard shortcuts

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