fragmentation

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MinFragment is minimum fragment size in bytes.
	MinFragment = core.FrameHeaderLen + 4
	// MaxFragment is minimum fragment size in bytes.
	MaxFragment = common.MaxUint24 - 3
)

Variables

This section is empty.

Functions

func IsValidFragment

func IsValidFragment(fragment int) (err error)

IsValidFragment validate fragment size.

func Split

func Split(mtu int, data []byte, metadata []byte, onFrame HandleSplitResult)

Split split data and metadata in frame.

func SplitSkip

func SplitSkip(mtu int, skip int, data []byte, metadata []byte, onFrame HandleSplitResult)

SplitSkip skip some bytes and split data and metadata in frame.

Types

type HandleSplitResult added in v0.6.0

type HandleSplitResult = func(index int, result SplitResult)

HandleSplitResult is callback for fragmentation result.

type HeaderAndPayload

type HeaderAndPayload interface {
	payload.Payload
	// FrameHeader returns a header of frame.
	Header() core.FrameHeader
}

HeaderAndPayload is Payload which having a FrameHeader.

type Joiner

type Joiner interface {
	HeaderAndPayload
	// First returns the first frame.
	First() core.Frame
	// Push append a new frame and returns true if joiner is end.
	Push(elem HeaderAndPayload) (end bool)
}

Joiner is used to join frames to a payload.

func NewJoiner

func NewJoiner(first HeaderAndPayload) Joiner

NewJoiner returns a new joiner.

type SplitResult added in v0.6.0

type SplitResult struct {
	Flag     core.FrameFlag
	Metadata []byte
	Data     []byte
}

SplitResult defines fragmentation result struct.

Jump to

Keyboard shortcuts

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