compress

package
v0.0.0-...-46ed21b Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package compress 提供数据压缩和解压缩功能

Index

Constants

View Source
const DefaultThreshold = 1024 // 1KB

压缩阈值:超过此大小的数据才进行压缩

Variables

This section is empty.

Functions

This section is empty.

Types

type Compressor

type Compressor interface {
	Compress(data []byte) ([]byte, error)
	Decompress(data []byte) ([]byte, error)
	Type() uint8
}

Compressor 压缩器接口

type GzipCompressor

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

GzipCompressor gzip 压缩器

func NewGzipCompressor

func NewGzipCompressor(threshold, level int) *GzipCompressor

NewGzipCompressor 创建 gzip 压缩器

func (*GzipCompressor) Compress

func (c *GzipCompressor) Compress(data []byte) ([]byte, error)

Compress 压缩数据

func (*GzipCompressor) Decompress

func (c *GzipCompressor) Decompress(data []byte) ([]byte, error)

Decompress 解压数据

func (*GzipCompressor) ShouldCompress

func (c *GzipCompressor) ShouldCompress(size int) bool

ShouldCompress 判断是否需要压缩

func (*GzipCompressor) Type

func (c *GzipCompressor) Type() uint8

Type 返回压缩类型

Jump to

Keyboard shortcuts

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