Documentation ¶
Overview ¶
Package objfile implements encoding and decoding of object files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
NewReader returns a new Reader reading from r.
func (*Reader) Close ¶
Close releases any resources consumed by the Reader. Calling Close does not close the wrapped io.Reader originally passed to NewReader.
func (*Reader) 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 ¶
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 ¶
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 ¶
Close releases any resources consumed by the Writer.
Calling Close does not close the wrapped io.Writer originally passed to NewWriter.
func (*Writer) 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 ¶
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.