aboutsummaryrefslogtreecommitdiff
path: root/object/blob_serialize.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-02-20 21:20:35 +0800
committerGravatar Runxi Yu2026-02-20 21:51:00 +0800
commitb5a545a3d883026d61beac5556fec2a45e9ec3d3 (patch)
tree6281f89df21cb4b63a16bbcb057c5f186c40b148 /object/blob_serialize.go
parenttestgit: Add test harnesses (diff)
signatureNo signature
object: Add basic object code
Diffstat (limited to 'object/blob_serialize.go')
-rw-r--r--object/blob_serialize.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/object/blob_serialize.go b/object/blob_serialize.go
new file mode 100644
index 00000000..c1818c20
--- /dev/null
+++ b/object/blob_serialize.go
@@ -0,0 +1,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
+}