1package dag
 2
 3import (
 4	"github.com/MichaelMure/git-bug/entity"
 5	"github.com/MichaelMure/git-bug/repository"
 6	"github.com/MichaelMure/git-bug/util/lamport"
 7)
 8
 9// Interface define the extended interface of a dag.Entity
10type Interface[SnapT Snapshot, OpT Operation] interface {
11	entity.Interface
12
13	// Validate checks if the Entity data is valid
14	Validate() error
15
16	// Append an operation into the staging area, to be committed later
17	Append(op OpT)
18
19	// Operations returns the ordered operations
20	Operations() []OpT
21
22	// NeedCommit indicates that the in-memory state changed and need to be committed in the repository
23	NeedCommit() bool
24
25	// Commit writes the staging area in Git and move the operations to the packs
26	Commit(repo repository.ClockedRepo) error
27
28	// FirstOp lookup for the very first operation of the Entity.
29	FirstOp() OpT
30
31	// LastOp lookup for the very last operation of the Entity.
32	// For a valid Entity, should never be nil
33	LastOp() OpT
34
35	// Compile a bug in an easily usable snapshot
36	Compile() SnapT
37
38	// CreateLamportTime return the Lamport time of creation
39	CreateLamportTime() lamport.Time
40
41	// EditLamportTime return the Lamport time of the last edit
42	EditLamportTime() lamport.Time
43}