textio

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const MaxCanonicalBufferBytes uint64 = 33_554_432

Variables

This section is empty.

Functions

This section is empty.

Types

type Budget

type Budget struct {
	MaxRawBytes uint64
	Deadline    time.Time
	Charge      func(rawBytes uint64) error
}

Budget bounds physical reads. A zero deadline disables the time check.

type CanonicalBuffer

type CanonicalBuffer struct {
	Summary Summary
	Bytes   []byte
	Lines   []LineOffset
}

func BufferCanonical

func BufferCanonical(ctx context.Context, file *rootfs.File, domain Domain, budget Budget, maxCanonicalBytes uint64) (CanonicalBuffer, api.ErrorCode)

func (CanonicalBuffer) Footprint

func (buffer CanonicalBuffer) Footprint() uint64

Footprint counts the retained backing arrays exactly once.

func (CanonicalBuffer) Line

func (buffer CanonicalBuffer) Line(number uint32) ([]byte, bool)

type Domain

type Domain struct {
	ThroughLine uint32
}

Domain selects a canonical prefix. Zero means the complete file.

type Encoding

type Encoding string

Encoding is one member of the closed v2 text encoding matrix.

const (
	EncodingUTF8    Encoding = "utf-8"
	EncodingUTF16BE Encoding = "utf-16be"
	EncodingUTF16LE Encoding = "utf-16le"
	EncodingUTF32BE Encoding = "utf-32be"
	EncodingUTF32LE Encoding = "utf-32le"
)

type Line

type Line struct {
	Number  uint64
	Bytes   []byte
	ByteLen uint64
	TooLong bool
}

Line is valid only for the duration of Consume.

type LineOffset

type LineOffset struct {
	Number uint32
	Start  uint32
	End    uint32
}

type LineSink

type LineSink interface {
	Consume(Line) error
}

type RangeLine

type RangeLine struct {
	Number uint32
	Text   string
}

RangeLine owns one literal selected source line.

type RangeSink

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

RangeSink copies only lines in an already validated inclusive range.

func NewRangeSink

func NewRangeSink(start, end uint32, maxBytes uint64) (*RangeSink, api.ErrorCode)

func (*RangeSink) Consume

func (sink *RangeSink) Consume(line Line) error

func (*RangeSink) Finish

func (sink *RangeSink) Finish(summary Summary) api.ErrorCode

Finish validates EOF clamping. Empty files always produce an empty range.

func (*RangeSink) TakeLines

func (sink *RangeSink) TakeLines() []RangeLine

TakeLines transfers the selected literal rows after a successful Finish.

type Summary

type Summary struct {
	Encoding  Encoding
	FinalLF   bool
	SHA256    [32]byte
	RawRead   uint64
	LineCount uint64
}

Summary describes the complete selected canonical domain.

func StreamCanonical

func StreamCanonical(ctx context.Context, file *rootfs.File, domain Domain, budget Budget, sink LineSink) (Summary, api.ErrorCode)

StreamCanonical decodes one selected domain without reopening or closing file.

Jump to

Keyboard shortcuts

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