From e936d246576e8bf714dbf8666e9349a5f22be87e Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 21 Feb 2026 01:47:11 +0800 Subject: objectstore: Rename from objectdb --- objectstore/objectstore.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 objectstore/objectstore.go (limited to 'objectstore/objectstore.go') diff --git a/objectstore/objectstore.go b/objectstore/objectstore.go new file mode 100644 index 00000000..ea906c70 --- /dev/null +++ b/objectstore/objectstore.go @@ -0,0 +1,33 @@ +// Package objectstore provides storage interfaces for Git objects. +package objectstore + +import ( + "errors" + "io" + + "codeberg.org/lindenii/furgit/objectid" + "codeberg.org/lindenii/furgit/objecttype" +) + +// ErrObjectNotFound indicates that an object does not exist in a backend. +// TODO: This might need to be an interface or otherwise be able to encapsulate multiple concrete backends' +var ErrObjectNotFound = errors.New("objectstore: object not found") + +// ObjectStore reads Git objects by object ID. +type ObjectStore interface { + // ReadBytesFull reads a full serialized object as "type size\\x00content". + // If hashed with the same algorithm it MUST match the object ID. + ReadBytesFull(id objectid.ObjectID) ([]byte, error) + // ReadBytesContent reads an object's type and content bytes. + ReadBytesContent(id objectid.ObjectID) (objecttype.Type, []byte, error) + // ReadReaderFull reads a full serialized object stream as "type size\\x00content". + // Caller must close the returned reader. + ReadReaderFull(id objectid.ObjectID) (io.ReadCloser, error) + // ReadReaderContent reads an object's type and content stream. + // Caller must close the returned reader. + ReadReaderContent(id objectid.ObjectID) (objecttype.Type, io.ReadCloser, error) + // ReadHeader reads an object's type and declared content length. + ReadHeader(id objectid.ObjectID) (objecttype.Type, int64, error) + // Close releases resources associated with the backend. + Close() error +} -- cgit v1.3.1-10-gc9f91