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