aboutsummaryrefslogtreecommitdiff
path: root/object/blob_serialize.go
blob: c1818c20f15c9c259b5ee3bc12fee6609ea6b20b (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
package object

// Serialize renders the raw object (header + body).
func (blob *Blob) Serialize() ([]byte, error) {
	header, err := headerForType(TypeBlob, blob.Data)
	if err != nil {
		return nil, err
	}
	raw := make([]byte, len(header)+len(blob.Data))
	copy(raw, header)
	copy(raw[len(header):], blob.Data)
	return raw, nil
}