source

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Slice

func Slice(src Source, start, end int64) ([]byte, error)

Slice is a convenience helper built on ReadAt.

Types

type BoundedSource

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

BoundedSource exposes a [start,end) view over a base source. Reads and lengths are expressed in local coordinates.

func NewBounded

func NewBounded(base Source, start, end int64) (*BoundedSource, error)

NewBounded is part of the experimental JSONKit API.

func (*BoundedSource) BaseEnd

func (s *BoundedSource) BaseEnd() int64

func (*BoundedSource) BaseStart

func (s *BoundedSource) BaseStart() int64

func (*BoundedSource) Len

func (s *BoundedSource) Len() int64

func (*BoundedSource) Name

func (s *BoundedSource) Name() string

func (*BoundedSource) ReadAt

func (s *BoundedSource) ReadAt(p []byte, off int64) (int, error)

type BufferedSource

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

BufferedSource reduces repeated small ReadAt calls by caching a fixed-size window from an underlying source.

func NewBuffered

func NewBuffered(base Source, blockSize int64) *BufferedSource

NewBuffered wraps base with a block cache. Non-positive blockSize falls back to a default.

func (*BufferedSource) Len

func (s *BufferedSource) Len() int64

func (*BufferedSource) Name

func (s *BufferedSource) Name() string

func (*BufferedSource) ReadAt

func (s *BufferedSource) ReadAt(p []byte, off int64) (int, error)

func (*BufferedSource) Revision

func (s *BufferedSource) Revision() Revision

type BytesSource

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

BytesSource is part of the experimental JSONKit API.

func ApplyEdits

func ApplyEdits(src Source, edits []Edit) (*BytesSource, error)

ApplyEdits requires edits to be pre-sorted by (Start, End). Overlapping edits are rejected.

Returned revision policy: - input implements Revisioned: output revision is input.Revision()+1 - input does not implement Revisioned: output revision is 0

func NewBytes

func NewBytes(name string, b []byte) *BytesSource

NewBytes is part of the experimental JSONKit API.

func (*BytesSource) Bytes

func (s *BytesSource) Bytes() []byte

Bytes returns the underlying immutable byte slice view. Callers must treat this as read-only.

func (*BytesSource) Len

func (s *BytesSource) Len() int64

func (*BytesSource) Name

func (s *BytesSource) Name() string

func (*BytesSource) ReadAt

func (s *BytesSource) ReadAt(p []byte, off int64) (int, error)

func (*BytesSource) Revision

func (s *BytesSource) Revision() Revision

type Edit

type Edit struct {
	Start  int64
	End    int64
	Insert []byte
}

Edit is part of the experimental JSONKit API.

type EditError

type EditError struct {
	Kind   EditErrorKind
	Edit   Edit
	Index  int
	Detail string
}

EditError is part of the experimental JSONKit API.

func (*EditError) Error

func (e *EditError) Error() string

type EditErrorKind

type EditErrorKind uint8

EditErrorKind is part of the experimental JSONKit API.

const (
	// EditErrorNegativeOffset is an experimental JSONKit constant.
	EditErrorNegativeOffset EditErrorKind = iota + 1
	// EditErrorInvertedRange is an experimental JSONKit constant.
	EditErrorInvertedRange
	// EditErrorOutOfBounds is an experimental JSONKit constant.
	EditErrorOutOfBounds
	// EditErrorUnsorted is an experimental JSONKit constant.
	EditErrorUnsorted
	// EditErrorOverlap is an experimental JSONKit constant.
	EditErrorOverlap
	// EditErrorNilSource is an experimental JSONKit constant.
	EditErrorNilSource
)

func (EditErrorKind) String

func (k EditErrorKind) String() string

type FileSource

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

FileSource is a file-backed source that reads directly from an open file. The owner must call Close when finished.

func OpenFile

func OpenFile(path string) (*FileSource, error)

OpenFile is part of the experimental JSONKit API.

func (*FileSource) Close

func (s *FileSource) Close() error

func (*FileSource) Len

func (s *FileSource) Len() int64

func (*FileSource) Name

func (s *FileSource) Name() string

func (*FileSource) ReadAt

func (s *FileSource) ReadAt(p []byte, off int64) (int, error)

func (*FileSource) Revision

func (s *FileSource) Revision() Revision

type RangeError

type RangeError struct {
	Kind  RangeErrorKind
	Start int64
	End   int64
	Len   int64
}

RangeError is part of the experimental JSONKit API.

func (*RangeError) Error

func (e *RangeError) Error() string

type RangeErrorKind

type RangeErrorKind uint8

RangeErrorKind is part of the experimental JSONKit API.

const (
	// RangeErrorNilSource is an experimental JSONKit constant.
	RangeErrorNilSource RangeErrorKind = iota + 1
	// RangeErrorNegativeOffset is an experimental JSONKit constant.
	RangeErrorNegativeOffset
	// RangeErrorStartAfterEnd is an experimental JSONKit constant.
	RangeErrorStartAfterEnd
	// RangeErrorOutOfBounds is an experimental JSONKit constant.
	RangeErrorOutOfBounds
)

func (RangeErrorKind) String

func (k RangeErrorKind) String() string

type Revision

type Revision int64

Revision is part of the experimental JSONKit API.

type Revisioned

type Revisioned interface {
	Revision() Revision
}

Revisioned is part of the experimental JSONKit API.

type Source

type Source interface {
	Name() string
	Len() int64
	ReadAt(p []byte, off int64) (n int, err error)
}

Source is part of the experimental JSONKit API.

func WrapBuffered

func WrapBuffered(base Source) Source

WrapBuffered returns base unchanged for nil, byte-backed, and already buffered sources; otherwise it applies default buffering.

Jump to

Keyboard shortcuts

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