compression

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: BSD-3-Clause Imports: 8 Imported by: 3

Documentation

Overview

Package compression implements reading and writing of compressed files.

This package is specifically designed for the LZMA formats used by popular UEFI implementations.

Index

Constants

This section is empty.

Variables

View Source
var (
	LZMAGUID    = *guid.MustParse("EE4E5898-3914-4259-9D6E-DC7BD79403CF")
	LZMAX86GUID = *guid.MustParse("D42AE6BD-1352-4BFB-909A-CA72A6EAE889")
)

Well-known GUIDs for GUIDed sections containing compressed data.

Functions

This section is empty.

Types

type Compressor

type Compressor interface {
	// Name is typically the name of a class.
	Name() string

	// Decode and Encode obey "x == Decode(Encode(x))".
	Decode(encodedData []byte) ([]byte, error)
	Encode(decodedData []byte) ([]byte, error)
}

Compressor defines a single compression scheme (such as LZMA).

func CompressorFromGUID

func CompressorFromGUID(guid *guid.GUID) Compressor

CompressorFromGUID returns a Compressor for the corresponding GUIDed Section.

type LZ4 added in v1.2.0

type LZ4 struct{}

LZ4 implements Compressor and uses a Go-based implementation.

func (*LZ4) Decode added in v1.2.0

func (c *LZ4) Decode(encodedData []byte) ([]byte, error)

Decode decodes a byte slice of LZ4 data.

func (*LZ4) Encode added in v1.2.0

func (c *LZ4) Encode(decodedData []byte) ([]byte, error)

Encode encodes a byte slice with LZ4.

func (*LZ4) Name added in v1.2.0

func (c *LZ4) Name() string

Name returns the type of compression employed.

type LZMA

type LZMA struct{}

LZMA implements Compressor and uses a Go-based implementation.

func (*LZMA) Decode

func (c *LZMA) Decode(encodedData []byte) ([]byte, error)

Decode decodes a byte slice of LZMA data.

func (*LZMA) Encode

func (c *LZMA) Encode(decodedData []byte) ([]byte, error)

Encode encodes a byte slice with LZMA.

func (*LZMA) Name

func (c *LZMA) Name() string

Name returns the type of compression employed.

type LZMAX86

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

LZMAX86 implements Compressor and includes the X86 filter which is popular in some UEFI implementations.

func (*LZMAX86) Decode

func (c *LZMAX86) Decode(encodedData []byte) ([]byte, error)

Decode decodes LZMA data with the x86 extension.

func (*LZMAX86) Encode

func (c *LZMAX86) Encode(decodedData []byte) ([]byte, error)

Encode encodes LZMA data with the x86 extension.

func (*LZMAX86) Name

func (c *LZMAX86) Name() string

Name returns the type of compression employed.

type SystemLZMA

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

SystemLZMA implements Compression and calls out to the system's compressor (except for Decode which uses the Go-based decompressor). The sytem's compressor is typically faster and generates smaller files than the Go-based implementation.

func (*SystemLZMA) Decode

func (c *SystemLZMA) Decode(encodedData []byte) ([]byte, error)

Decode decodes a byte slice of LZMA data.

func (*SystemLZMA) Encode

func (c *SystemLZMA) Encode(decodedData []byte) ([]byte, error)

Encode encodes a byte slice with LZMA.

func (*SystemLZMA) Name

func (c *SystemLZMA) Name() string

Name returns the type of compression employed.

Jump to

Keyboard shortcuts

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