blob: 3e0352d1b31051a27832bebde83cb90248e21547 (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// Package stored wraps parsed objects with their storage object IDs.
//
// Stored values are typically instantiated with pointer object types such as
// *object.Blob, *object.Tree, *object.Commit, or *object.Tag, because those
// pointer types satisfy object.Object.
package stored
import (
"codeberg.org/lindenii/furgit/object"
"codeberg.org/lindenii/furgit/objectid"
)
// Stored represents a stored object,
// i.e., an object along with its object ID.
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
}
|