split

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2025 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStreamDialer

func NewStreamDialer(dialer transport.StreamDialer, nextSplit SplitIterator) (transport.StreamDialer, error)

NewStreamDialer creates a transport.StreamDialer that splits the outgoing stream according to nextSplit.

func NewWriter

func NewWriter(writer io.Writer, nextSegmentLength SplitIterator) io.Writer

NewWriter creates a split Writer that calls the nextSegmentLength SplitIterator to determine the number bytes until the next split point until it returns zero.

Types

type RepeatedSplit

type RepeatedSplit struct {
	Count int
	Bytes int64
}

RepeatedSplit represents a split sequence of count segments with bytes length.

type SplitIterator

type SplitIterator func() int64

SplitIterator is a function that returns how many bytes until the next split point, or zero if there are no more splits to do.

func NewFixedSplitIterator

func NewFixedSplitIterator(n int64) SplitIterator

NewFixedSplitIterator is a helper function that returns a SplitIterator that returns the input number once, followed by zero. This is helpful for when you want to split the stream once in a fixed position.

func NewRepeatedSplitIterator

func NewRepeatedSplitIterator(splits ...RepeatedSplit) SplitIterator

NewRepeatedSplitIterator is a helper function that returns a SplitIterator that returns split points according to splits. The splits input represents pairs of (count, bytes), meaning a sequence of count splits with bytes length. This is helpful for when you want to split the stream repeatedly at different positions and lengths.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳