git/odb/pack: introduce *Chain type
This commit is contained in:
parent
9ea23ca017
commit
c7f13cdab2
21
git/odb/pack/chain.go
Normal file
21
git/odb/pack/chain.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package pack
|
||||||
|
|
||||||
|
// Chain represents an element in the delta-base chain corresponding to a packed
|
||||||
|
// object.
|
||||||
|
type Chain interface {
|
||||||
|
// Unpack unpacks the data encoded in the delta-base chain up to and
|
||||||
|
// including the receiving Chain implementation by applying the
|
||||||
|
// delta-base chain successively to itself.
|
||||||
|
//
|
||||||
|
// If there was an error in the delta-base resolution, i.e., the chain
|
||||||
|
// is malformed, has a bad instruction, or there was an mmap-related
|
||||||
|
// read error, this function is expected to return that error.
|
||||||
|
//
|
||||||
|
// In the event that a non-nil error is returned, it is assumed that the
|
||||||
|
// unpacked data this function returns is malformed, or otherwise
|
||||||
|
// corrupt.
|
||||||
|
Unpack() ([]byte, error)
|
||||||
|
|
||||||
|
// Type returns the type of the receiving chain element.
|
||||||
|
Type() PackedObjectType
|
||||||
|
}
|
12
git/odb/pack/chain_test.go
Normal file
12
git/odb/pack/chain_test.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package pack
|
||||||
|
|
||||||
|
type ChainSimple struct {
|
||||||
|
X []byte
|
||||||
|
Err error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ChainSimple) Unpack() ([]byte, error) {
|
||||||
|
return c.X, c.Err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ChainSimple) Type() PackedObjectType { return TypeNone }
|
Loading…
Reference in New Issue
Block a user