| 1 |
package gitobj |
| 2 |
|
| 3 |
import ( |
| 4 |
"hash" |
| 5 |
"io" |
| 6 |
) |
| 7 |
|
| 8 |
// Object is an interface satisfied by any concrete type that represents a loose |
| 9 |
// Git object. |
| 10 |
type Object interface { |
| 11 |
// Encode takes an io.Writer, "to", and encodes an uncompressed |
| 12 |
// Git-compatible representation of itself to that stream. |
| 13 |
// |
| 14 |
// It must return "n", the number of uncompressed bytes written to that |
| 15 |
// stream, along with "err", any error that was encountered during the |
| 16 |
// write. |
| 17 |
// |
| 18 |
// Any error that was encountered should be treated as "fatal-local", |
| 19 |
// meaning that a particular invocation of Encode() cannot progress, and |
| 20 |
// an accurate number "n" of bytes written up that point should be |
| 21 |
// returned. |
| 22 |
Encode(to io.Writer) (n int, err error) |
| 23 |
|
| 24 |
// Decode takes an io.Reader, "from" as well as a size "size" (the |
| 25 |
// number of uncompressed bytes on the stream that represent the object |
| 26 |
// trying to be decoded) and decodes the encoded object onto itself, |
| 27 |
// as a mutative transaction. |
| 28 |
// |
| 29 |
// It returns the number of uncompressed bytes "n" that an invoication |
| 30 |
// of this function has advanced the io.Reader, "from", as well as any |
| 31 |
// error that was encountered along the way. |
| 32 |
// |
| 33 |
// If an(y) error was encountered, it should be returned immediately, |
| 34 |
// along with the number of bytes read up to that point. |
| 35 |
Decode(hash hash.Hash, from io.Reader, size int64) (n int, err error) |
| 36 |
|
| 37 |
// Type returns the ObjectType constant that represents an instance of |
| 38 |
// the implementing type. |
| 39 |
Type() ObjectType |
| 40 |
} |