cfh

package module
v0.0.0-...-1ed14dd Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: AGPL-3.0 Imports: 5 Imported by: 0

README

CompressFrameHeader

Use dictionary compression algorithm to reduce the transmission of frame header data

Documentation

Index

Constants

View Source
const (
	// MaxFrameHeaderSize is the maximum frame header.
	MaxFrameHeaderSize = 256

	// MaxDictionarySize is the maximum dictionary size.
	MaxDictionarySize = 256
)

Variables

This section is empty.

Functions

func IsFrameHeaderPreferBeCompressed

func IsFrameHeaderPreferBeCompressed(frame []byte) (int, bool)

IsFrameHeaderPreferBeCompressed is used to check frame header can be compressed by fast mode. If frame header is preferred be compressed, it will return the header size that be compressed. It supports IPv4/IPv6 with TCP/UDP

Types

type Reader

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

Reader is used to decompress frame header data.

func NewReader

func NewReader(r io.Reader) *Reader

NewReader is used to create a new compressor with 256 dictionaries.

func NewReaderWithSize

func NewReaderWithSize(r io.Reader, size int) (*Reader, error)

NewReaderWithSize is used to create a new decompressor with custom number of dictionaries.

func (*Reader) Read

func (r *Reader) Read(b []byte) (int, error)

Read is used to decompress frame header data from the under r and copy to b.

type Searcher

type Searcher = func(dict [][]byte, header []byte) (index int)

Searcher is used to fast search dictionaries for custom frame header. Dict is the Writer inner saved dictionaries. If cannot to search the target dictionary, return the index -1.

type Writer

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

Writer is used to compress frame header data.

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter is used to create a new compressor with 256 dictionaries.

func NewWriterWithSize

func NewWriterWithSize(w io.Writer, size int) (*Writer, error)

NewWriterWithSize is used to create a new compressor with custom number of dictionaries.

func (*Writer) RegisterSearcher

func (w *Writer) RegisterSearcher(size int, searcher Searcher) error

RegisterSearcher is used to register custom searcher for fast search dictionaries with custom frame header. Size is the target frame header size.

func (*Writer) Write

func (w *Writer) Write(b []byte) (int, error)

Write is used to compress frame header data and write to the under w.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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