fragmentation

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MinFragment is minimum fragment size in bytes.
	MinFragment = framing.HeaderLen + 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 func(idx int, fg framing.FrameFlag, body *common.ByteBuff))

Split split data and metadata in frame.

func SplitSkip

func SplitSkip(mtu int, skip int, data []byte, metadata []byte, onFrame func(idx int, fg framing.FrameFlag, body *common.ByteBuff))

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

Types

type HeaderAndPayload

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

HeaderAndPayload is Payload which having a FrameHeader.

type Joiner

type Joiner interface {
	HeaderAndPayload
	// First returns the first frame.
	First() framing.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.

Jump to

Keyboard shortcuts

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