disk: Entity types must implement Clone()

All disk.Entitity types now implement Clone() which should return a
deep copy of the same object. Add the Clone() method to the entity
interface. The return type is Entity, but callers can assume it's
safe to convert back to the original type.

Co-Authored-By: Christian Kellner <christian@kellner.me>
This commit is contained in:
Achilleas Koutsou 2022-02-08 12:22:46 +01:00 committed by Tom Gundersen
parent 01d922a4d5
commit 221cdedebc
8 changed files with 158 additions and 24 deletions

View file

@ -35,6 +35,9 @@ type Entity interface {
// IsContainer indicates if the implementing type can
// contain any other entities.
IsContainer() bool
// Clone returns a deep copy of the entity.
Clone() Entity
}
// Container is the interface for entities that can contain other entities.