compression

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: Apache-2.0 Imports: 8 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewUnsupportedCompressionTypeError

func NewUnsupportedCompressionTypeError(t string) error

NewUnsupportedCompressionTypeError create a new unsupported compression type error

Types

type CompressedBytes

type CompressedBytes struct {
	Type Type   `json:"type,omitempty"`
	Data []byte `json:"data,omitempty"`
}

CompressedBytes represents compressed data and which compression method is used. It stores compressed data in binary form.

func (*CompressedBytes) Clean

func (c *CompressedBytes) Clean()

Clean clears the compressed data.

func (*CompressedBytes) DecodeTo

func (c *CompressedBytes) DecodeTo(obj interface{}) error

DecodeTo decodes the compressed data and unmarshal it into the given object. obj must be a pointer.

func (*CompressedBytes) EncodeFrom

func (c *CompressedBytes) EncodeFrom(obj interface{}) (err error)

EncodeFrom encodes the given data using the given compression type. Note that it first JSON-marshals the object, then compresses it.

func (*CompressedBytes) SetType

func (c *CompressedBytes) SetType(t Type)

SetType sets the compression type.

type CompressedText

type CompressedText struct {
	Type Type   `json:"type,omitempty"`
	Data string `json:"data,omitempty"`
}

CompressedText represents compressed data and which compression method is used. It stores compressed data in text form (base64), which can be used in JSON, yaml, etc.

func (*CompressedText) Clean

func (c *CompressedText) Clean()

Clean clears the compressed data.

func (*CompressedText) DecodeTo

func (c *CompressedText) DecodeTo(obj interface{}) error

DecodeTo decodes the compressed data and unmarshal it into the given object. obj must be a pointer.

func (*CompressedText) EncodeFrom

func (c *CompressedText) EncodeFrom(obj interface{}) error

EncodeFrom encodes the given data using the given compression type. Note that it first JSON-marshals the object, compresses it, and encodes it in base64.

func (*CompressedText) SetType

func (c *CompressedText) SetType(t Type)

SetType sets the compression type.

type Type

type Type string

Type the compression type

const (
	// Uncompressed does not compress data. Note that you should NOT actually Uncompressed
	// Type. We do not provide a compressor for Uncompressed Type.
	// It is just for compatibility purposes.
	Uncompressed Type = ""
	// Gzip compresses data using gzip
	Gzip Type = "gzip"
	// Zstd compresses data using zstd
	Zstd Type = "zstd"
)

Jump to

Keyboard shortcuts

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