chunking

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: GPL-3.0 Imports: 7 Imported by: ? modules, 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.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChunkHandler

type ChunkHandler = func([]byte) error

ChunkHandler is the type of the function called to recieve chunks. the buffer should not be used outside of the function call.

type Chunker

type Chunker interface {
	// Write writes bytes to the chunker, chunks can be produced anywhere in the slice
	Write(p []byte) (int, error)
	// Buffered returns the number of bytes buffered, but not yet made into a chunk.
	Buffered() int
	// Flush forces the production of a chunk, if there is any buffered data.
	Flush() error
}

Chunker is the common interface exposed by chunkers

type ContentDefined

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

func NewContentDefined

func NewContentDefined(minSize, avgSize, maxSize int, key *[32]byte, onChunk func(data []byte) error) *ContentDefined

NewContentDefined creates a new content defined chunker. key must not be nil. Use new([32]byte) to give a key of all zeros.

func (*ContentDefined) Buffered

func (c *ContentDefined) Buffered() int

func (*ContentDefined) Flush

func (c *ContentDefined) Flush() error

func (*ContentDefined) MaxSize

func (c *ContentDefined) MaxSize() int

func (*ContentDefined) MeanSize

func (c *ContentDefined) MeanSize() int

func (*ContentDefined) MinSize

func (c *ContentDefined) MinSize() int

func (*ContentDefined) ReadFrom

func (c *ContentDefined) ReadFrom(r io.Reader) (int64, error)

func (*ContentDefined) Reset

func (c *ContentDefined) Reset()

func (*ContentDefined) Write

func (c *ContentDefined) Write(data []byte) (int, error)

func (*ContentDefined) WriteByte

func (c *ContentDefined) WriteByte(b byte) error

type Exponential

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

func NewExponential

func NewExponential(minSize, maxSize, period int, fn ChunkHandler) *Exponential

func (*Exponential) Buffered

func (e *Exponential) Buffered() int

func (*Exponential) Flush

func (e *Exponential) Flush() error

func (*Exponential) Reset

func (e *Exponential) Reset()

func (*Exponential) Write

func (e *Exponential) Write(data []byte) (int, error)

Jump to

Keyboard shortcuts

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