chunking

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: GPL-3.0 Imports: 7 Imported by: 0

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 added in v0.0.4

func (c *ContentDefined) MaxSize() int

func (*ContentDefined) MeanSize added in v0.0.4

func (c *ContentDefined) MeanSize() int

func (*ContentDefined) MinSize added in v0.0.4

func (c *ContentDefined) MinSize() int

func (*ContentDefined) ReadFrom added in v0.0.3

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