diff options
Diffstat (limited to 'object/store/memory/write_bytes.go')
| -rw-r--r-- | object/store/memory/write_bytes.go | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/object/store/memory/write_bytes.go b/object/store/memory/write_bytes.go deleted file mode 100644 index 241169d9..00000000 --- a/object/store/memory/write_bytes.go +++ /dev/null @@ -1,35 +0,0 @@ -package memory - -import ( - "bytes" - - objectheader "codeberg.org/lindenii/furgit/object/header" - objectid "codeberg.org/lindenii/furgit/object/id" - objecttype "codeberg.org/lindenii/furgit/object/type" -) - -// WriteBytesContent writes one typed object content byte slice. -func (store *Store) WriteBytesContent(ty objecttype.Type, content []byte) (objectid.ObjectID, error) { - id := store.algo.Sum(buildRawObject(ty, content)) - store.objects[id] = storedObject{ty: ty, content: append([]byte(nil), content...)} - - return id, nil -} - -// WriteBytesFull writes one full serialized object byte slice as "type size\0content". -func (store *Store) WriteBytesFull(raw []byte) (objectid.ObjectID, error) { - return store.WriteReaderFull(bytes.NewReader(raw)) -} - -func buildRawObject(ty objecttype.Type, body []byte) []byte { - header, ok := objectheader.Encode(ty, int64(len(body))) - if !ok { - panic("failed to encode object header") - } - - raw := make([]byte, len(header)+len(body)) - copy(raw, header) - copy(raw[len(header):], body) - - return raw -} |
