aboutsummaryrefslogtreecommitdiff
path: root/obj_blob.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2025-11-16 00:00:00 +0000
committerGravatar Runxi Yu2025-11-16 00:00:00 +0000
commit94bfb1fa147f80e6ec39009d41fc2f853925e0a5 (patch)
treee2c8063f3fbc58527e21f1f88e72f9e32071c28a /obj_blob.go
parentREADME: Remove example program as it's unmaintainable now (diff)
signature
hash: Generic hash-algorithm API
Diffstat (limited to 'obj_blob.go')
-rw-r--r--obj_blob.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/obj_blob.go b/obj_blob.go
index 9edad0a9..1f74464e 100644
--- a/obj_blob.go
+++ b/obj_blob.go
@@ -1,27 +1,26 @@
package furgit
// Blob represents the contents of a Git blob.
-type Blob struct {
- Hash Hash
-
+type Blob[T HashType] struct {
+ Hash Hash[T]
Data []byte
}
// ObjType allows Blob to satisfy the Object interface.
-func (*Blob) ObjType() ObjType {
+func (*Blob[T]) ObjType() ObjType {
return ObjBlob
}
-func parseBlob(id Hash, body []byte) (*Blob, error) {
+func parseBlob[T HashType](id Hash[T], body []byte) (*Blob[T], error) {
data := append([]byte(nil), body...)
- return &Blob{
+ return &Blob[T]{
Hash: id,
Data: data,
}, nil
}
// Serialize renders the full "blob size\\0body" representation.
-func (b *Blob) Serialize(hashSize int) ([]byte, error) {
+func (b *Blob[T]) Serialize() ([]byte, error) {
header, err := headerForType(ObjBlob, b.Data)
if err != nil {
return nil, err