objfile

package
v5.1.4 Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package objfile implements encoding and decoding of object files.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClosed       = errors.New("objfile: already closed")
	ErrHeader       = errors.New("objfile: invalid header")
	ErrNegativeSize = errors.New("objfile: negative object size")
)
View Source
var (
	ErrOverflow = errors.New("objfile: declared data length exceeded (overflow)")
)

Functions

This section is empty.

Types

type Reader

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

Reader reads and decodes compressed objfile data from a provided io.Reader. Reader implements io.ReadCloser. Close should be called when finished with the Reader. Close will not close the underlying io.Reader.

func NewReader

func NewReader(r io.Reader) (*Reader, error)

NewReader returns a new Reader reading from r.

func (*Reader) Close

func (r *Reader) Close() error

Close releases any resources consumed by the Reader. Calling Close does not close the wrapped io.Reader originally passed to NewReader.

func (*Reader) Hash

func (r *Reader) Hash() plumbing.Hash

Hash returns the hash of the object data stream that has been read so far.

func (*Reader) Header

func (r *Reader) Header() (t plumbing.ObjectType, size int64, err error)

Header reads the type and the size of object, and prepares the reader for read

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Read reads len(p) bytes into p from the object data stream. It returns the number of bytes read (0 <= n <= len(p)) and any error encountered. Even if Read returns n < len(p), it may use all of p as scratch space during the call.

If Read encounters the end of the data stream it will return err == io.EOF, either in the current call if n > 0 or in a subsequent call.

type Writer

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

Writer writes and encodes data in compressed objfile format to a provided io.Writer. Close should be called when finished with the Writer. Close will not close the underlying io.Writer.

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter returns a new Writer writing to w.

The returned Writer implements io.WriteCloser. Close should be called when finished with the Writer. Close will not close the underlying io.Writer.

func (*Writer) Close

func (w *Writer) Close() error

Close releases any resources consumed by the Writer.

Calling Close does not close the wrapped io.Writer originally passed to NewWriter.

func (*Writer) Hash

func (w *Writer) Hash() plumbing.Hash

Hash returns the hash of the object data stream that has been written so far. It can be called before or after Close.

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Write writes the object's contents. Write returns the error ErrOverflow if more than size bytes are written after WriteHeader.

func (*Writer) WriteHeader

func (w *Writer) WriteHeader(t plumbing.ObjectType, size int64) error

WriteHeader writes the type and the size and prepares to accept the object's contents. If an invalid t is provided, plumbing.ErrInvalidType is returned. If a negative size is provided, ErrNegativeSize is returned.

Jump to

Keyboard shortcuts

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