secio

package
v0.0.0-...-9fcf0b5 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0, MIT Imports: 2 Imported by: 3

Documentation

Overview

Package secio provides support for sectioned I/O.

Index

Constants

This section is empty.

Variables

View Source
var ErrReachedLimit = errors.New("reached limit")

ErrReachedLimit is returned when SectionReader.Read or SectionWriter.Write reaches its limit.

Functions

This section is empty.

Types

type FullReader

type FullReader struct {
	Reader io.Reader
}

FullReader adapts an io.Reader to never return partial reads with a nil error.

func (FullReader) Read

func (r FullReader) Read(dst []byte) (int, error)

Read implements io.Reader.Read.

type SectionReader

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

SectionReader implements io.Reader on a section of an underlying io.ReaderAt. It is similar to io.SectionReader, but:

  • Reading beyond the limit returns ErrReachedLimit, not io.EOF.

  • Limit overflow is handled correctly.

func NewOffsetReader

func NewOffsetReader(r io.ReaderAt, off int64) *SectionReader

NewOffsetReader returns an io.Reader that reads from r starting at offset off.

func NewSectionReader

func NewSectionReader(r io.ReaderAt, off int64, n int64) *SectionReader

NewSectionReader returns an io.Reader that reads from r starting at offset off and stops with ErrReachedLimit after n bytes.

func (*SectionReader) Read

func (r *SectionReader) Read(dst []byte) (int, error)

Read implements io.Reader.Read.

type SectionWriter

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

SectionWriter implements io.Writer on a section of an underlying io.WriterAt. Writing beyond the limit returns ErrReachedLimit.

func NewOffsetWriter

func NewOffsetWriter(w io.WriterAt, off int64) *SectionWriter

NewOffsetWriter returns an io.Writer that writes to w starting at offset off.

func NewSectionWriter

func NewSectionWriter(w io.WriterAt, off int64, n int64) *SectionWriter

NewSectionWriter returns an io.Writer that writes to w starting at offset off and stops with ErrReachedLimit after n bytes.

func (*SectionWriter) Write

func (w *SectionWriter) Write(src []byte) (int, error)

Write implements io.Writer.Write.

Jump to

Keyboard shortcuts

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