diff options
| author | 2026-04-02 08:16:04 +0000 | |
|---|---|---|
| committer | 2026-04-02 08:16:04 +0000 | |
| commit | 510a6a3d09d6fc010fecc0d87e6d838fecc3a6df (patch) | |
| tree | de753fab31de495f682e46f4f10d71518a63c6cf /object/store/reader.go | |
| parent | furgit: Fix doc whitespace (diff) | |
| signature | No signature | |
object/store: Add interfaces
Diffstat (limited to 'object/store/reader.go')
| -rw-r--r-- | object/store/reader.go | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/object/store/reader.go b/object/store/reader.go new file mode 100644 index 00000000..ac1a10ee --- /dev/null +++ b/object/store/reader.go @@ -0,0 +1,61 @@ +package store + +import ( + "io" + + "codeberg.org/lindenii/furgit/object/id" + "codeberg.org/lindenii/furgit/object/typ" +) + +// Reader reads Git objects by object ID. +// +// Methods may perform implementation-defined integrity verification +// beyond successfully producing their documented result. +// +// Labels: MT-Safe. +type Reader interface { + // ReadBytesFull reads a full serialized object as "type size\0content". + // + // In a valid repository, + // hashing this payload with the same algorithm + // yields the requested object ID. + // Users should treat this as an invariant; + // implementations should not re-verify it on every read. + // + // Labels: Life-Parent. + ReadBytesFull(id id.ObjectID) ([]byte, error) + + // ReadBytesContent reads an object's type and content bytes. + // + // Labels: Life-Parent. + ReadBytesContent(id id.ObjectID) (typ.Type, []byte, error) + + // ReadReaderFull reads a full serialized object stream + // as "type size\0content". + // + // Labels: Life-Parent, Close-Caller. + ReadReaderFull(id id.ObjectID) (io.ReadCloser, error) + + // ReadReaderContent reads an object's type, + // declared content length, and content stream. + // + // Labels: Life-Parent, Close-Caller. + ReadReaderContent(id id.ObjectID) (typ.Type, int64, io.ReadCloser, error) + + // ReadSize reads an object's declared content length. + // + // This is equivalent to ReadHeader(...).size; + // for some implementations, this may be cheaper than ReadHeader + // when callers do not need object type. + ReadSize(id id.ObjectID) (int64, error) + + // ReadHeader reads an object's type and declared content length. + ReadHeader(id id.ObjectID) (typ.Type, int64, error) + + // Refresh updates any backend-local discovery/cache view of on-disk objects. + // + // Backends without dynamic discovery should do nothing and return nil. + // + // TODO + Refresh() error +} |
