go-git.v4: gopkg.in/src-d/go-git.v4/plumbing/format/objfile Index | Files

package objfile

import "gopkg.in/src-d/go-git.v4/plumbing/format/objfile"

Package objfile implements encoding and decoding of object files.

Index

Package Files

doc.go reader.go writer.go

Variables

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

type Reader Uses

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 Uses

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

NewReader returns a new Reader reading from r.

func (*Reader) Close Uses

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 Uses

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

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

func (*Reader) Header Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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.

Package objfile imports 6 packages (graph) and is imported by 9 packages. Updated 2019-08-01. Refresh now. Tools for package owners.