diff options
| author | 2026-03-29 09:48:28 +0000 | |
|---|---|---|
| committer | 2026-03-29 09:48:28 +0000 | |
| commit | 74bf82fbf45118f0c1beae966de964d62670e3d2 (patch) | |
| tree | 9fcc9226ed938e2e2e5e7dcf43c5ea6b08fe1bfd /object | |
| parent | object: Update docs (diff) | |
| signature | No signature | |
object/stored: Split files and document properly
Diffstat (limited to 'object')
| -rw-r--r-- | object/stored/doc.go | 7 | ||||
| -rw-r--r-- | object/stored/id.go | 8 | ||||
| -rw-r--r-- | object/stored/new.go | 11 | ||||
| -rw-r--r-- | object/stored/object.go | 6 | ||||
| -rw-r--r-- | object/stored/stored.go | 20 |
5 files changed, 32 insertions, 20 deletions
diff --git a/object/stored/doc.go b/object/stored/doc.go new file mode 100644 index 00000000..d57cbd55 --- /dev/null +++ b/object/stored/doc.go @@ -0,0 +1,7 @@ +// Package stored wraps parsed objects with the object IDs they were loaded +// under. +// +// Parsed Git object values do not carry storage identity on their own. This +// package provides a small generic wrapper for the common case where callers +// need both the parsed object value and the object ID it was read from. +package stored diff --git a/object/stored/id.go b/object/stored/id.go new file mode 100644 index 00000000..956d069e --- /dev/null +++ b/object/stored/id.go @@ -0,0 +1,8 @@ +package stored + +import objectid "codeberg.org/lindenii/furgit/object/id" + +// ID returns the object ID. +func (stored *Stored[T]) ID() objectid.ObjectID { + return stored.id +} diff --git a/object/stored/new.go b/object/stored/new.go new file mode 100644 index 00000000..8b0ef881 --- /dev/null +++ b/object/stored/new.go @@ -0,0 +1,11 @@ +package stored + +import ( + "codeberg.org/lindenii/furgit/object" + objectid "codeberg.org/lindenii/furgit/object/id" +) + +// New creates one stored object wrapper. +func New[T object.Object](id objectid.ObjectID, obj T) *Stored[T] { + return &Stored[T]{id: id, obj: obj} +} diff --git a/object/stored/object.go b/object/stored/object.go new file mode 100644 index 00000000..ab22b9c8 --- /dev/null +++ b/object/stored/object.go @@ -0,0 +1,6 @@ +package stored + +// Object returns the wrapped object as itself. +func (stored *Stored[T]) Object() T { + return stored.obj +} diff --git a/object/stored/stored.go b/object/stored/stored.go index 4429a373..eb776f31 100644 --- a/object/stored/stored.go +++ b/object/stored/stored.go @@ -1,8 +1,3 @@ -// Package stored wraps parsed objects with their storage object IDs. -// -// Stored values are typically instantiated with pointer object types such as -// *blob.Blob, *tree.Tree, *commit.Commit, or *tag.Tag, because those -// pointer types satisfy object.Object. package stored import ( @@ -16,18 +11,3 @@ type Stored[T object.Object] struct { id objectid.ObjectID obj T } - -// New creates one stored object wrapper. -func New[T object.Object](id objectid.ObjectID, obj T) *Stored[T] { - return &Stored[T]{id: id, obj: obj} -} - -// ID returns the object ID. -func (stored *Stored[T]) ID() objectid.ObjectID { - return stored.id -} - -// Object returns the wrapped object as itself. -func (stored *Stored[T]) Object() T { - return stored.obj -} |
